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, Jason Merrill <jason@redhat.com> wrote:

> OK for the trunk.  Mark will have to rule on the branch.

Mark joined my paranoia :-) and approved (in private) the patch I had
posted first (the one that tweaked cp/decl.c:finish_enum()), so I'm
checking it in the branch, along with the following testcase.  I could
have implemented the test as a compile-only thing using template
trickery or even with negative-size arrays or duplicate case labels in
a switch, but hey!, I found this run-time test to be much more
readable, especially for those unfamiliar with such compile-time test
idioms, so I went on with it.

Index: gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* g++.dg/abi/enum1.C: New test.

Index: gcc/testsuite/g++.dg/abi/enum1.C
===================================================================
RCS file: gcc/testsuite/g++.dg/abi/enum1.C
diff -N gcc/testsuite/g++.dg/abi/enum1.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/g++.dg/abi/enum1.C 26 Apr 2002 19:44:17 -0000
@@ -0,0 +1,16 @@
+// { dg-do run }
+
+#include <cstdlib>
+
+enum foo
+{
+  foo1   = 0,
+  foo2   = 0xffffffffffffffffULL,
+  foo3   = 0xf0fffffffffffffeULL
+};
+
+int main (int i)
+{
+  if (sizeof (enum foo) != sizeof (unsigned long long))
+    std::abort ();
+}

-- 
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]