re PR c++/46282 ([C++0x] ICE: SIGSEGV in grokbitfield (decl2.c:1054))
authorJason Merrill <jason@redhat.com>
Tue, 1 Mar 2011 22:44:26 +0000 (17:44 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 1 Mar 2011 22:44:26 +0000 (17:44 -0500)
PR c++/46282
* decl2.c (grokbitfield): Handle type-dependent width.

From-SVN: r170600

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 d1b1b4aaf4ed4c69dcdd6029d00da9f4f2c060a4..ac3f4d71f2ea606e7ba8984df99e7882dc5511f2 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 93d44a4d6b5f3bd59d2bc49aff884348d0db558b..eb5d4f5a9c34ae109686f53923d98eba57820285 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 94bbe7ee6ec2f259d8afe6c9feb9ee7a41e73179..fed2d43e4d2016b8294daf2e61ffc9893e2f6f8f 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;
+};