summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-19 07:22:40 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2001-07-19 07:22:40 +0000
commit3a1fbde803a835ad2e3125846d5157bcc953cb68 (patch)
tree7ce475105e33da5098966b546460735c76d8d9f7
parent730cb0ccb0a6e2a19fb7c9bfd73eebf0d99a4634 (diff)
downloadgcc-3a1fbde803a835ad2e3125846d5157bcc953cb68.tar.gz
* class.c (finish_struct_anon): Forbid nested classes.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44148 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/class.c9
-rw-r--r--gcc/testsuite/g++.old-deja/g++.jason/anon3.C2
3 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0fa3fdb4bc8..fb7d6c1ec76 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 c3aa297236b..087b7c807ef 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 b3f05f8ad14..96353fcc97b 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;