]> gcc.gnu.org Git - gcc.git/commitdiff
* semantics.c (begin_class_definition): Robustify.
authorMark Mitchell <mark@codesourcery.com>
Wed, 6 Jun 2001 07:03:03 +0000 (07:03 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 6 Jun 2001 07:03:03 +0000 (07:03 +0000)
From-SVN: r42937

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C [new file with mode: 0644]

index 7c0ebc5f754f89d9a8437e823e6718f01dd079ba..829c4da9cbabcc353565d5912e79f6f17380cde7 100644 (file)
@@ -1,5 +1,7 @@
 2001-06-05  Mark Mitchell  <mark@codesourcery.com>
 
+       * semantics.c (begin_class_definition): Robustify.
+
        * pt.c (instantiate_decl): Tell the repository code about the
        clones, not the cloned functions.
        * repo.c (repo_template_used): Explicitly instantiate the cloned
index b30c80e8c3d687a92b60ab16b7b42213f6c0c73a..f1a9e77aa7d204d2468087b573186dd17f63359b 100644 (file)
@@ -1724,18 +1724,29 @@ begin_class_definition (t)
       cp_error ("definition of `%#T' inside template parameter list", t);
       return error_mark_node;
     }
-  if (t == error_mark_node
-      || ! IS_AGGR_TYPE (t))
+
+  /* In a definition of a member class template, we will get here with
+     an implicit typename.  */
+  if (IMPLICIT_TYPENAME_P (t))
+    t = TREE_TYPE (t);
+  /* A non-implicit typename comes from code like:
+
+       template <typename T> struct A {
+         template <typename U> struct A<T>::B ...
+
+     This is erroneous.  */
+  else if (TREE_CODE (t) == TYPENAME_TYPE)
+    {
+      cp_error ("invalid definition of qualified type `%T'", t);
+      t = error_mark_node;
+    }
+
+  if (t == error_mark_node || ! IS_AGGR_TYPE (t))
     {
       t = make_aggr_type (RECORD_TYPE);
       pushtag (make_anon_name (), t, 0);
     }
 
-  /* In a definition of a member class template, we will get here with an
-     implicit typename, a TYPENAME_TYPE with a type.  */
-  if (TREE_CODE (t) == TYPENAME_TYPE)
-    t = TREE_TYPE (t);
-  
   /* If we generated a partial instantiation of this type, but now
      we're seeing a real definition, we're actually looking at a
      partial specialization.  Consider:
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp99.C
new file mode 100644 (file)
index 0000000..2295bea
--- /dev/null
@@ -0,0 +1,10 @@
+// Build don't link:
+// Origin: bitti@cs.tut.fi
+
+template<typename T, unsigned int N>
+class Vector
+{
+public:
+  template<unsigned int I>
+  class Vector<T,N>::CommaInit { }; // ERROR - invalid definition
+};
This page took 0.103395 seconds and 5 git commands to generate.