diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0ccaeba1169..4e17539b35b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +1998-08-31 Mark Mitchell + + * decl.c (finish_enum): Handle member enums of classes declared in + template functions. + + * decl2.c (grok_x_components): Strip attributres before calling + groktypename. + 1998-08-31 Jason Merrill * cp-tree.h, decl2.c: Remove support for -fall-virtual, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3da20575fea..fe9160dc2c0 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11931,7 +11931,8 @@ finish_enum (enumtype) if (processing_template_decl) { - if (current_function_decl) + tree scope = current_scope (); + if (scope && TREE_CODE (scope) == FUNCTION_DECL) { add_tree (build_min (TAG_DEFN, enumtype)); resume_temporary_allocation (); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 3345b83a69d..04424bf147c 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -853,7 +853,8 @@ grok_x_components (specs, components) if (components == NULL_TREE) { - t = groktypename (build_decl_list (specs, NULL_TREE)); + t = groktypename (build_decl_list (strip_attrs (specs), + NULL_TREE)); if (t == NULL_TREE) { diff --git a/gcc/testsuite/g++.old-deja/g++.other/crash4.C b/gcc/testsuite/g++.old-deja/g++.other/crash4.C new file mode 100644 index 00000000000..d86a6bb3f66 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/crash4.C @@ -0,0 +1,7 @@ +// Build don't link: + +struct T { + struct S __attribute__ ((packed)) { // ERROR - parse error + int i; + }; +}; // ERROR - parse error diff --git a/gcc/testsuite/g++.old-deja/g++.pt/enum11.C b/gcc/testsuite/g++.old-deja/g++.pt/enum11.C new file mode 100644 index 00000000000..77631c41c6f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/enum11.C @@ -0,0 +1,10 @@ +// Build don't link: + +template void f1() +{ + struct foo { enum T2 { + un, du, toi }; + }; +} + +void f2() { f1(); }