aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-09-15 19:55:43 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-09-15 19:55:43 -0400
commit441b624e3d4b2be01deaf8156bd5ea2b39849259 (patch)
treefb7f920d5338a10375609c74215f95e478226b25 /gcc
parent02a39a93ce25e78a1698001e1fefd6d96f644231 (diff)
downloadgcc-441b624e3d4b2be01deaf8156bd5ea2b39849259.zip
gcc-441b624e3d4b2be01deaf8156bd5ea2b39849259.tar.gz
gcc-441b624e3d4b2be01deaf8156bd5ea2b39849259.tar.bz2
* decl2.c (grokbitfield): Diagnose non-integral width.
From-SVN: r164321
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog2
-rw-r--r--gcc/cp/decl2.c4
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C11
4 files changed, 21 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 27cb326..10630c2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index f233055..63197705 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1f8744..486c945 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C b/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C
new file mode 100644
index 0000000..e87b36a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/scoped_enum2.C
@@ -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
+};