]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: tweak parsing of invalid types
authorJason Merrill <jason@redhat.com>
Mon, 18 Oct 2021 20:12:15 +0000 (16:12 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 20 Oct 2021 21:40:13 +0000 (17:40 -0400)
commit1c690164668bda556f308632eab4204f63a138d7
tree55116db17696800765568f71ab396b90498378ce
parent788483f77de04515b0b72d3c4c841c37b005f404
c++: tweak parsing of invalid types

cp_parser_parse_and_diagnose_invalid_type_name is called during declaration
parsing, so it should pass 'true' for the declarator_p argument.  But that
caused a diagnostic regression on template/pr84789.C due to undesired lookup
in dependent scopes.  To fix that, cp_parser_nested_name_specifier_opt needs
to respect the value of check_dependency_p.

This patch avoids a regression from Andrew Sharp's WIP patch for PR70417.

It would make more sense to test only check_dependency_p, not declarator_p,
but removing the declarator_p condition turns out to reveal complicated
interactions of cp_parser_constructor_declarator_p and caching of
nested-name-specifiers and template-ids that I've already spent too much
time trying to sort out.

gcc/cp/ChangeLog:

* parser.c (cp_parser_parse_and_diagnose_invalid_type_name):
Pass true for declarator_p.
(cp_parser_nested_name_specifier_opt): Only look through
TYPENAME_TYPE if check_dependency_p is false.
gcc/cp/parser.c