This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch for enum bug



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();
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]