re PR c++/16162 (Rejects valid member-template-definition)
authorMark Mitchell <mark@codesourcery.com>
Tue, 14 Sep 2004 05:44:39 +0000 (05:44 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 14 Sep 2004 05:44:39 +0000 (05:44 +0000)
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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/decl2.C [new file with mode: 0644]

index 010320136ddc4141938070ff7fdb259216a1cfae..6d53c933a49ad250300c1c6469320dcb757e1810 100644 (file)
@@ -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.
index 6ac5c717d3f21be9fb3f176ba7d20a5aa2b368e6..05f447a6325bced67a5a9c22fead75598d478488 100644 (file)
@@ -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.  */
index 356701cfe4217dcee95a976edc53b11619cbc374..4e59e16fbcb85b1916a481a9fda334ff15fd0928 100644 (file)
@@ -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 (file)
index 0000000..3a77777
--- /dev/null
@@ -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 () {}