Comments
Patch
@@ -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;
new file mode 100644
@@ -0,0 +1,9 @@
+// PR c++/46282
+// { dg-options -std=c++0x }
+
+template<int>
+class A
+{
+ A : i() {} // { dg-message "" }
+ int i;
+};
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.