https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87386
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- With: --- gcc/cp/parser.c.jj 2018-11-20 08:41:28.686923718 +0100 +++ gcc/cp/parser.c 2018-11-20 17:06:27.942626189 +0100 @@ -5602,7 +5602,7 @@ cp_parser_primary_expression (cp_parser /*is_namespace=*/false, /*check_dependency=*/true, &ambiguous_decls, - id_expr_token->location); + id_expression.get_location ()); /* If the lookup was ambiguous, an error will already have been issued. */ if (ambiguous_decls) @@ -5673,7 +5673,7 @@ cp_parser_primary_expression (cp_parser if (parser->local_variables_forbidden_p && local_variable_p (decl)) { - error_at (id_expr_token->location, + error_at (id_expression.get_location (), "local variable %qD may not appear in this context", decl.get_value ()); return error_mark_node; @@ -5692,7 +5692,7 @@ cp_parser_primary_expression (cp_parser id_expression.get_location ())); if (error_msg) cp_parser_error (parser, error_msg); - decl.set_location (id_expr_token->location); + decl.set_location (id_expression.get_location ()); return decl; } @@ -5758,6 +5758,7 @@ cp_parser_id_expression (cp_parser *pars { bool global_scope_p; bool nested_name_specifier_p; + location_t start_loc = cp_lexer_peek_token (parser->lexer)->location; /* Assume the `template' keyword was not used. */ if (template_p) @@ -5809,6 +5810,9 @@ cp_parser_id_expression (cp_parser *pars parser->object_scope = saved_object_scope; parser->qualifying_scope = saved_qualifying_scope; + location_t loc = make_location (unqualified_id.get_start (), start_loc, + unqualified_id.get_finish ()); + unqualified_id.set_location (loc); return unqualified_id; } /* Otherwise, if we are in global scope, then we are looking at one the output is: pr87386.C:4:31: error: static assertion failed: foo 4 | static_assert(foo::test<int>::value, "foo"); | ~~~~~~~~~~~~~~~~^~~~~ pr87386.C:5:37: error: static assertion failed: bar 5 | static_assert(foo::test<int>::value && true, "bar"); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ Is that what we want? I.e. put the care at the start of the identifier in the id-expression and use range of the whole id-expression? We'd need to adjust probably g++.dg/cpp0x/auto52.C g++.dg/cpp0x/pr51420.C g++.dg/cpp0x/udlit-declare-neg.C g++.dg/lookup/suggestions2.C g++.dg/parse/error17.C g++.dg/spellcheck-pr77829.C g++.dg/spellcheck-pr78656.C g++.dg/spellcheck-pr79298.C g++.dg/spellcheck-single-vs-multiple.C testcases, so before I do that I'd like to get agreement if this is the right thing to do. David?