This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: underlying type of C++ enums [changes ABI, ok for 3.1?]


On Apr 26, 2002, Mark Mitchell <mark@codesourcery.com> wrote:

>> Mark, your call.

> OK, go with the patch that Jason approved.  Let's hope we were too paranoid
> before.

/me crosses fingers :-)

Ok, I'm checking it in, along with the following additional testcase.

Tested on athlon-pc-linux-gnu.

Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>
	* gcc.dg/enum1.c: New test.

Index: gcc/testsuite/gcc.dg/enum1.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/enum1.c
diff -N gcc/testsuite/gcc.dg/enum1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/enum1.c 26 Apr 2002 23:39:57 -0000
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-std=gnu89" } */
+
+/* In standard C, enumeration constants always have type int.  If they
+   are not representables are int, they're ill-formed.  In GNU C, we
+   give such ill-formed constructs well-defined meaning.  Make sure it
+   works.  */
+
+#include <stdlib.h>
+
+enum foo
+{
+  foo1   = 0,
+  foo2   = 0xffffffffffffffffULL,
+  foo3   = 0xf0fffffffffffffeULL
+};
+
+int main ()
+{
+  if (sizeof (enum foo) != sizeof (unsigned long long))
+    abort ();
+  exit (0);
+}

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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