decl.c (pushtag): Avoid crashing on erroneous input.
authorMark Mitchell <mark@markmitchell.com>
Tue, 26 May 1998 07:02:37 +0000 (07:02 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 26 May 1998 07:02:37 +0000 (07:02 +0000)
1998-05-25  Mark Mitchell  <mark@markmitchell.com>
* decl.c (pushtag): Avoid crashing on erroneous input.

From-SVN: r20056

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

index 7d01a2ecd70d6938d195586c901ce6856fbbc9fe..c04f9c89c1b6ff5db49fafe94ffb16821adb1ff2 100644 (file)
@@ -1,3 +1,7 @@
+1998-05-26  Mark Mitchell  <mark@markmitchell.com>
+
+       * decl.c (pushtag): Avoid crashing on erroneous input.
+
 1998-05-25  Martin v. Löwis  <loewis@informatik.hu-berlin.de>
 
        * decl.c (push_namespace): Only produce one unique name for
index bcdb558f7c1fa924eac5a6fdedc1cbba92669c30..804e2251b8dbdec3a83289822b91071e5054c1da 100644 (file)
@@ -2236,7 +2236,16 @@ pushtag (name, type, globalize)
          TYPE_NAME (type) = d;
          DECL_CONTEXT (d) = context;
 
-         if (IS_AGGR_TYPE (type)
+         if (processing_template_parmlist)
+           /* You can't declare a new template type in a template
+              parameter list.  But, you can declare a non-template
+              type:
+
+                template <class A*> struct S;
+
+              is a forward-declaration of `A'.  */
+           ;
+         else if (IS_AGGR_TYPE (type)
              && (/* If !GLOBALIZE then we are looking at a
                     definition.  It may not be a primary template.
                     (For example, in:
@@ -2255,15 +2264,9 @@ pushtag (name, type, globalize)
                         friend class S2; 
                       };
 
-                    declares S2 to be at global scope.  We must be
-                    careful, however, of the following case:
-
-                      template <class A*> struct S;
-
-                    which declares a non-template class `A'.  */
-                 || (!processing_template_parmlist
-                     && (processing_template_decl > 
-                         template_class_depth (current_class_type)))))
+                    declares S2 to be at global scope.  */
+                 || (processing_template_decl > 
+                     template_class_depth (current_class_type))))
            {
              d = push_template_decl_real (d, globalize);
              /* If the current binding level is the binding level for
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash7.C b/gcc/testsuite/g++.old-deja/g++.pt/crash7.C
new file mode 100644 (file)
index 0000000..9ee7b2c
--- /dev/null
@@ -0,0 +1,10 @@
+// Build don't link:
+
+class foo 
+{
+};
+
+template <class T : public foo> // ERROR - base clause
+struct bar
+{
+};