PR c++/46282
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Mar 2011 22:44:26 +0000 (22:44 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 1 Mar 2011 22:44:26 +0000 (22:44 +0000)
* decl2.c (grokbitfield): Handle type-dependent width.

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

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C [new file with mode: 0644]

index d1b1b4a..ac3f4d7 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/46282
+       * decl2.c (grokbitfield): Handle type-dependent width.
+
 2011-02-28  Jason Merrill  <jason@redhat.com>
 
        PR c++/47873
index 93d44a4..eb5d4f5 100644 (file)
@@ -1052,7 +1052,8 @@ 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)))
+      if (!type_dependent_expression_p (width)
+         && !INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (TREE_TYPE (width)))
        error ("width of bit-field %qD has non-integral type %qT", value,
               TREE_TYPE (width));
       DECL_INITIAL (value) = width;
index 94bbe7e..fed2d43 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-01  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/bitfield-err1.C: New.
+
 2011-03-01  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/47890
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C b/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C
new file mode 100644 (file)
index 0000000..a2e9d47
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/46282
+// { dg-options -std=c++0x }
+
+template<int>
+class A
+{
+  A : i() {}                   // { dg-message "" }
+  int i;
+};