* decl.c (build_enumerator): Don't perform integral promotions on
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 16:30:08 +0000 (16:30 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Feb 2011 16:30:08 +0000 (16:30 +0000)
non-integral constants.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170008 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/ext-label10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/label10.C

index 7d9667d..20b0d4b 100644 (file)
@@ -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
index 6a13cc4..866069d 100644 (file)
@@ -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);
            }
index 97d2caf..dc522e3 100644 (file)
@@ -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 (file)
index 0000000..652d94a
--- /dev/null
@@ -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:;
+}
index 735fe06..632b242 100644 (file)
@@ -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:;
 }