This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Patch for enum bug
- To: Jason Merrill <jason at cygnus dot com>
- Subject: Patch for enum bug
- From: Mark Mitchell <mmitchell at usa dot net>
- Date: Thu, 22 Jan 1998 21:33:20 -0800
- Cc: egcs-bugs at cygnus dot com, Markus dot Schoder at dresdner-bank dot de
- Reply-to: mmitchell at usa dot net
Markus --
Here's a patch for the problem you reported with code like this:
extern "C" void abort();
struct A
{
enum { a = 3}* p;
int f() { return (int) a; }
};
int main()
{
A a;
if (a.f() != 3)
abort();
}
--
Mark Mitchell mmitchell@usa.net
Stanford University http://www.stanford.edu
Thu Jan 22 21:30:42 1998 Mark Mitchell <mmitchell@usa.net>
* decl2.c (grok_x_components): Always call grok_enum_decls.
Index: gcc/cp/decl2.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/decl2.c,v
retrieving revision 1.3
diff -c -p -r1.3 decl2.c
*** decl2.c 1998/01/12 18:25:28 1.3
--- decl2.c 1998/01/23 05:08:54
*************** grok_x_components (specs, components)
*** 931,940 ****
else
{
t = TREE_TYPE (components);
! if (TREE_CODE (t) == ENUMERAL_TYPE && TREE_NONLOCAL_FLAG (t))
! return grok_enum_decls (t, components);
! else
! return components;
}
}
--- 931,937 ----
else
{
t = TREE_TYPE (components);
! return grok_enum_decls (t, components);
}
}
Index: gcc/testsuite/g++.old-deja/g++.other/enum1.C
===================================================================
RCS file: enum1.C
diff -N enum1.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- enum1.C Thu Jan 22 21:12:24 1998
***************
*** 0 ****
--- 1,15 ----
+ extern "C" void abort();
+
+ struct A
+ {
+ enum { a = 3}* p;
+ int f() { return (int) a; }
+ };
+
+ int main()
+ {
+ A a;
+
+ if (a.f() != 3)
+ abort();
+ }