Commit b7076960 by Mark Mitchell Committed by Mark Mitchell

* class.c (finish_struct_anon): Forbid nested classes.

From-SVN: r44148
parent 69e6b1d4
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> 2001-07-19 Neil Booth <neil@daikokuya.demon.co.uk>
* decl2.c: Don't include dwarfout.h and dwarf2out.h. * decl2.c: Don't include dwarfout.h and dwarf2out.h.
......
...@@ -3132,7 +3132,14 @@ finish_struct_anon (t) ...@@ -3132,7 +3132,14 @@ finish_struct_anon (t)
tree elt = TYPE_FIELDS (TREE_TYPE (field)); tree elt = TYPE_FIELDS (TREE_TYPE (field));
for (; elt; elt = TREE_CHAIN (elt)) 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; continue;
if (DECL_NAME (elt) == constructor_name (t)) if (DECL_NAME (elt) == constructor_name (t))
......
...@@ -8,7 +8,7 @@ public: ...@@ -8,7 +8,7 @@ public:
private: private:
union { union {
float vf; float vf;
struct ff { struct ff { // ERROR - nested class in anonymous union
void *ptr; void *ptr;
char *name; char *name;
int sz; int sz;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment