diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d01a2ecd70d6938d195586c901ce6856fbbc9fe..c04f9c89c1b6ff5db49fafe94ffb16821adb1ff2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bcdb558f7c1fa924eac5a6fdedc1cbba92669c30..804e2251b8dbdec3a83289822b91071e5054c1da 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 0000000000000000000000000000000000000000..9ee7b2c665ded7163e5116f320497fd03becc5e3 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash7.C @@ -0,0 +1,10 @@ +// Build don't link: + +class foo +{ +}; + +template <class T : public foo> // ERROR - base clause +struct bar +{ +};