diff options
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/decl2.C | 13 |
4 files changed, 35 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0103201..6d53c93 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,12 @@ 2004-09-13 Mark Mitchell <mark@codesourcery.com> + 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 6ac5c71..05f447a 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<T>::I::Y<T>" we must be able to + look up names in "X<T>::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 356701c..4e59e16 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-09-13 Mark Mitchell <mark@codesourcery.com> + + PR c++/16162 + * g++.dg/template/decl2.C: New test. + 2004-09-13 Bud Davis <bdavis9659@comcast.net> 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 0000000..3a77777 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/decl2.C @@ -0,0 +1,13 @@ +// PR c++/16162 + +template <int N> struct O { + struct I { + template <typename T> struct II { + void f(); + }; + }; +}; + +template <int N> +template <typename T> +void O<N>::I::II<T>::f () {} |