* decl2.c (grokbitfield): Diagnose non-integral width.

From-SVN: r164321
This commit is contained in:
Jason Merrill 2010-09-15 19:55:43 -04:00 committed by Jason Merrill
parent 02a39a93ce
commit 441b624e3d
4 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,7 @@
2010-09-15 Jason Merrill <jason@redhat.com>
* decl2.c (grokbitfield): Diagnose non-integral width.
* call.c (convert_like_real): Use the underlying type of the
reference for the temporary.

View File

@ -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);

View File

@ -1,3 +1,7 @@
2010-09-15 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/scoped_enum2.C: New.
2010-09-15 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/compile/20100915-1.c: New test.

View File

@ -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
};