diff options
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/label10.C | 6 |
5 files changed, 28 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7d9667d..20b0d4b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-02-09 Jason Merrill <jason@redhat.com> + * decl.c (build_enumerator): Don't perform integral promotions on + non-integral constants. + * cvt.c (convert_to_void): Handle null op1. * class.c (type_has_constexpr_default_constructor): Make sure the diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6a13cc4..866069d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -11869,7 +11869,8 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) { value = cxx_constant_value (value); - if (TREE_CODE (value) == INTEGER_CST) + if (TREE_CODE (value) == INTEGER_CST + && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (value))) { value = perform_integral_promotions (value); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 97d2caf..dc522e3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-02-09 Jason Merrill <jason@redhat.com> + * g++.dg/ext/label10.C: Adjust for C++0x mode. + * g++.dg/cpp0x/regress/ext-label10.C: Copy it. + * g++.dg/cpp0x/regress/ext-cond1.C: Copy from ext/cond1.C. * g++.dg/cpp0x/regress/abi-empty7.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C b/gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C new file mode 100644 index 0000000..652d94a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C @@ -0,0 +1,17 @@ +// PR c++/33836 +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +template<int N> struct A +{ + enum { M = && N }; // { dg-error "referenced outside|cannot appear in|not an integer constant" } +}; + +A<0> a; + +void foo () +{ + __label__ P; + enum { O = && P }; // { dg-error "cannot appear in|not an integer constant" } + P:; +} diff --git a/gcc/testsuite/g++.dg/ext/label10.C b/gcc/testsuite/g++.dg/ext/label10.C index 735fe06..632b242 100644 --- a/gcc/testsuite/g++.dg/ext/label10.C +++ b/gcc/testsuite/g++.dg/ext/label10.C @@ -1,10 +1,10 @@ // PR c++/33836 // { dg-do compile } -// { dg-options "-std=gnu++98" } +// { dg-options "" } template<int N> struct A { - enum { M = && N }; // { dg-error "referenced outside|cannot appear in" } + enum { M = && N }; // { dg-error "referenced outside|cannot appear in|not an integer constant" } }; A<0> a; @@ -12,6 +12,6 @@ A<0> a; void foo () { __label__ P; - enum { O = && P }; // { dg-error "cannot appear in" } + enum { O = && P }; // { dg-error "cannot appear in|not an integer constant" } P:; } |