This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]