From a52eb3bc7c904e73e3cbd53c0439b970143064cc Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Tue, 14 Sep 2004 05:44:39 +0000 Subject: [PATCH] re PR c++/16162 (Rejects valid member-template-definition) PR c++/16162 * parser.c (cp_parser_id_expression): Correct value for is_declarator. (cp_parser_nested_name_specifier_opt): Look through typenames as necessary. (cp_parser_template_name): Honor check_dependency_p. PR c++/16162 * g++.dg/template/decl2.C: New test. From-SVN: r87483 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 11 ++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/decl2.C | 13 +++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/decl2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 010320136dd..6d53c933a49 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2004-09-13 Mark Mitchell + PR c++/16162 + * parser.c (cp_parser_id_expression): Correct value for + is_declarator. + (cp_parser_nested_name_specifier_opt): Look through typenames as + necessary. + (cp_parser_template_name): Honor check_dependency_p. + PR c++/16716 * parser.c (cp_parser_parse_and_diagnose_invalid_type_name): Robustify. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6ac5c717d3f..05f447a6325 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3053,7 +3053,7 @@ cp_parser_id_expression (cp_parser *parser, /*typename_keyword_p=*/false, check_dependency_p, /*type_p=*/false, - /*is_declarator=*/false) + declarator_p) != NULL_TREE); /* If there is a nested-name-specifier, then we are looking at the first qualified-id production. */ @@ -3493,6 +3493,14 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, might destroy it. */ old_scope = parser->scope; saved_qualifying_scope = parser->qualifying_scope; + /* In a declarator-id like "X::I::Y" we must be able to + look up names in "X::I" in order to determine that "Y" is + a template. So, if we have a typename at this point, we make + an effort to look through it. */ + if (is_declaration && parser->scope + && TREE_CODE (parser->scope) == TYPENAME_TYPE) + parser->scope = resolve_typename_type (parser->scope, + /*only_current_p=*/false); /* Parse the qualifying entity. */ new_scope = cp_parser_class_or_namespace_name (parser, @@ -8671,6 +8679,7 @@ cp_parser_template_name (cp_parser* parser, if (is_declaration && !template_keyword_p && parser->scope && TYPE_P (parser->scope) + && check_dependency_p && dependent_type_p (parser->scope) /* Do not do this for dtors (or ctors), since they never need the template keyword before their name. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 356701cfe42..4e59e16fbcb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-13 Mark Mitchell + + PR c++/16162 + * g++.dg/template/decl2.C: New test. + 2004-09-13 Bud Davis PR fortran/17090 diff --git a/gcc/testsuite/g++.dg/template/decl2.C b/gcc/testsuite/g++.dg/template/decl2.C new file mode 100644 index 00000000000..3a77777bd0a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/decl2.C @@ -0,0 +1,13 @@ +// PR c++/16162 + +template struct O { + struct I { + template struct II { + void f(); + }; + }; +}; + +template +template +void O::I::II::f () {} -- 2.30.2