diff options
author | Mark Mitchell <mark@markmitchell.com> | 1998-05-26 07:02:37 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-05-26 07:02:37 +0000 |
commit | 312a0c90730e796c40ae8e52b4575d4043668d9b (patch) | |
tree | 0af7ace6b5a2d16031018e312c7cf73fdcf21174 | |
parent | 954b0af841e6d7cee4754d4d8a93878ffa38edee (diff) | |
download | gcc-312a0c90730e796c40ae8e52b4575d4043668d9b.zip gcc-312a0c90730e796c40ae8e52b4575d4043668d9b.tar.gz gcc-312a0c90730e796c40ae8e52b4575d4043668d9b.tar.bz2 |
decl.c (pushtag): Avoid crashing on erroneous input.
1998-05-25 Mark Mitchell <mark@markmitchell.com>
* decl.c (pushtag): Avoid crashing on erroneous input.
From-SVN: r20056
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/crash7.C | 10 |
3 files changed, 27 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d01a2e..c04f9c8 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 bcdb558..804e225 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 0000000..9ee7b2c --- /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 +{ +}; |