diff options
author | Mark Mitchell <mark@codesourcery.com> | 2001-07-19 07:22:40 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2001-07-19 07:22:40 +0000 |
commit | b7076960b306190210070be081ea318d7eb17d21 (patch) | |
tree | 7ce475105e33da5098966b546460735c76d8d9f7 | |
parent | 69e6b1d4b21986afb0c4051b7b2dca3ba6bc59cb (diff) | |
download | gcc-b7076960b306190210070be081ea318d7eb17d21.zip gcc-b7076960b306190210070be081ea318d7eb17d21.tar.gz gcc-b7076960b306190210070be081ea318d7eb17d21.tar.bz2 |
* class.c (finish_struct_anon): Forbid nested classes.
From-SVN: r44148
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/class.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.jason/anon3.C | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0fa3fdb..fb7d6c1e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2001-07-19 Mark Mitchell <mark@codesourcery.com> + + * class.c (finish_struct_anon): Forbid nested classes. + 2001-07-19 Neil Booth <neil@daikokuya.demon.co.uk> * decl2.c: Don't include dwarfout.h and dwarf2out.h. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c3aa297..087b7c8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3132,7 +3132,14 @@ finish_struct_anon (t) tree elt = TYPE_FIELDS (TREE_TYPE (field)); for (; elt; elt = TREE_CHAIN (elt)) { - if (DECL_ARTIFICIAL (elt)) + /* We're generally only interested in entities the user + declared, but we also find nested classes by noticing + the TYPE_DECL that we create implicitly. You're + allowed to put one anonymous union inside another, + though, so we explicitly tolerate that. */ + if (DECL_ARTIFICIAL (elt) + && (!DECL_IMPLICIT_TYPEDEF_P (elt) + || ANON_AGGR_TYPE_P (TREE_TYPE (elt)))) continue; if (DECL_NAME (elt) == constructor_name (t)) diff --git a/gcc/testsuite/g++.old-deja/g++.jason/anon3.C b/gcc/testsuite/g++.old-deja/g++.jason/anon3.C index b3f05f8..96353fc 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/anon3.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/anon3.C @@ -8,7 +8,7 @@ public: private: union { float vf; - struct ff { + struct ff { // ERROR - nested class in anonymous union void *ptr; char *name; int sz; |