commit bb4f84e102b0828f0318c1b64dbb2025d5b4acc4
Author: Jason Merrill <jason@redhat.com>
Date: Wed Sep 15 15:25:12 2010 -0400
* decl2.c (grokbitfield): Diagnose non-integral width.
@@ -1066,6 +1066,10 @@ grokbitfield (const cp_declarator *declarator,
if (width != error_mark_node)
{
+ /* The width must be an integer type. */
+ if (!INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width)))
+ error ("width of bit-field %qD has non-integral type %qT", value,
+ TREE_TYPE (width));
constant_expression_warning (width);
DECL_INITIAL (value) = width;
SET_DECL_C_BIT_FIELD (value);
new file mode 100644
@@ -0,0 +1,11 @@
+// { dg-options -std=c++0x }
+
+enum class E { e = 10 };
+enum E2 { e2 = 10 };
+
+struct C {
+ int arr[E::e]; // { dg-error "non-integral type" }
+ int arr2[E2::e2]; // OK
+ int i: E::e; // { dg-error "non-integral type" }
+ int i2: E2::e2; // OK
+};