diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2008-10-19 13:52:10 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2008-10-19 13:52:10 +0000 |
commit | a7e72022ce7fbf78637fb8475e9c357f00ff120d (patch) | |
tree | a603fc519ad66ae66ae8c855cbe58febdfac8c54 /gcc/testsuite/gcc.dg/pr30260.c | |
parent | 1344d3908deca2a7c40c18aba6bebebc963ceecc (diff) | |
download | gcc-a7e72022ce7fbf78637fb8475e9c357f00ff120d.tar.gz |
re PR c/30260 (Enumeration types and enumeration constants erroneously given unsigned types)
2008-10-19 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/30260
* c-decl.c (finish_enum): Convert non-integer enumerators to enum
type.
(build_enumerator): Convert enumerators that fit in integer to
integer type.
testsuite/
* gcc.dg/pr30260.c: New.
From-SVN: r141224
Diffstat (limited to 'gcc/testsuite/gcc.dg/pr30260.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr30260.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr30260.c b/gcc/testsuite/gcc.dg/pr30260.c new file mode 100644 index 00000000000..f7373176ed5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr30260.c @@ -0,0 +1,32 @@ +/* PR 30260 */ +/* { dg-do link } */ +/* { dg-options "-pedantic -O" } */ +#include <limits.h> + +enum A { + A1 = 0, + A2 = A1 - 1 +}; +enum B { + B1 = 0u, + B2 = B1 - 1 /* { dg-bogus "ISO C restricts enumerator values to range of 'int'" } */ +}; +int main(void) +{ + enum A a = -1; + enum B b = -1; + + if (!(a < 0)) + link_error (); + if (!(A2 < 0)) + link_error (); + if (!(b < 0)) + link_error (); + if (!(B2 < 0)) + link_error (); + + return 0; +} + +enum E1 { e10 = INT_MAX, e11 }; /* { dg-error "overflow in enumeration values" } */ +enum E2 { e20 = (unsigned) INT_MAX, e21 }; /* { dg-error "overflow in enumeration values" } */ |