From: Mark Mitchell Date: Tue, 26 May 1998 07:02:37 +0000 (+0000) Subject: decl.c (pushtag): Avoid crashing on erroneous input. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=312a0c90730e796c40ae8e52b4575d4043668d9b;p=gcc.git decl.c (pushtag): Avoid crashing on erroneous input. 1998-05-25 Mark Mitchell * decl.c (pushtag): Avoid crashing on erroneous input. From-SVN: r20056 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d01a2ecd70..c04f9c89c1b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +1998-05-26 Mark Mitchell + + * decl.c (pushtag): Avoid crashing on erroneous input. + 1998-05-25 Martin v. Löwis * decl.c (push_namespace): Only produce one unique name for diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bcdb558f7c1..804e2251b8d 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 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 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 00000000000..9ee7b2c665d --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash7.C @@ -0,0 +1,10 @@ +// Build don't link: + +class foo +{ +}; + +template // ERROR - base clause +struct bar +{ +};