diff options
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/enum8.C | 11 |
4 files changed, 26 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b4a3df4..c602721 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2012-01-01 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/16603 + * decl.c (build_enumerator): Don't call perform_integral_promotions + on the value. + +2012-01-01 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/51379 * typeck.c (build_reinterpret_cast_1): Implement resolution of DR 799. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2fc794b..48f3085 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12369,14 +12369,11 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) { value = cxx_constant_value (value); - if (TREE_CODE (value) == INTEGER_CST - && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))) + if (TREE_CODE (value) != INTEGER_CST + || ! INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))) { - value = perform_integral_promotions (value); - } - else - { - error ("enumerator value for %qD is not an integer constant", name); + error ("enumerator value for %qD is not an integer constant", + name); value = NULL_TREE; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cfbef8d..3e35722 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2012-01-01 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/16603 + * g++.dg/parse/enum8.C: New. + +2012-01-01 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/51379 * g++.dg/conversion/reinterpret4.C: New. * g++.dg/conversion/reinterpret1.C: Adjust. diff --git a/gcc/testsuite/g++.dg/parse/enum8.C b/gcc/testsuite/g++.dg/parse/enum8.C new file mode 100644 index 0000000..83dd6e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/enum8.C @@ -0,0 +1,11 @@ +// PR c++/16603 + +char const c = 'q'; + +enum + { + x = c, + y = sizeof(x) + }; + +int test[y == sizeof(char) ? 1 : -1]; |