diff mbox

C++ PATCH for c++/46282 (ICE on invalid in grokbitfield)

Message ID 4D6D751A.2070609@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 1, 2011, 10:37 p.m. UTC
Testing the code of TREE_TYPE (width) doesn't work too well if TREE_TYPE 
(width) is null, as for a type-dependent expression.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 48accfb6db3a227ccecbcaef809cfb89db42484d
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 1 01:32:00 2011 -0500

    	PR c++/46282
    	* decl2.c (grokbitfield): Handle type-dependent width.
diff mbox

Patch

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 93d44a4..eb5d4f5 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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;
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
index 0000000..a2e9d47
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/regress/bitfield-err1.C
@@ -0,0 +1,9 @@ 
+// PR c++/46282
+// { dg-options -std=c++0x }
+
+template<int>
+class A
+{
+  A : i() {}			// { dg-message "" }
+  int i;
+};