re PR c++/16603 (Incorrect enumerator type before enumeration's closing brace)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 1 Jan 2012 22:33:31 +0000 (22:33 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 1 Jan 2012 22:33:31 +0000 (22:33 +0000)
/cp
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.

/testsuite
2012-01-01  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/16603
* g++.dg/parse/enum8.C: New.

From-SVN: r182776

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/enum8.C [new file with mode: 0644]

index b4a3df4e4e95f80c1c384b51db036e13ffba301e..c60272131875b5cb37409fb0a5c8652a91ff3956 100644 (file)
@@ -1,3 +1,9 @@
+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
index 2fc794b30ee7f99350804a7f903f7c6130d7f661..48f3085a92f1a43ed25902dcb4b406e66f18d531 100644 (file)
@@ -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;
            }
        }
index cfbef8d6a83edef48daaf70cdd2cbf2ca7409db8..3e357228c7bac140b883c6a101f071302f5a146d 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/parse/enum8.C b/gcc/testsuite/g++.dg/parse/enum8.C
new file mode 100644 (file)
index 0000000..83dd6e0
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/16603
+
+char const c = 'q';
+
+enum
+  {
+    x = c,
+    y = sizeof(x)
+  };
+
+int test[y == sizeof(char) ? 1 : -1];