* decl2.c (grokbitfield): Detect invalid non-integral
types earlier when possible.
* g++.dg/parse/bitfield1.C: Adjust error markers.
* g++.dg/parse/bitfield2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117910
138bc75d-0d04-0410-961f-
82ee72b054a4
+2006-10-20 Lee Millward <lee.millward@codesourcery.com>
+ Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/28053
+ * decl2.c (grokbitfield): Detect invalid non-integral
+ types earlier when possible.
+
2006-10-18 Mark Shinwell <shinwell@codesourcery.com>
PR c++/26884
if (TREE_CODE (value) == VOID_TYPE)
return void_type_node;
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (value))
+ && (POINTER_TYPE_P (value)
+ || !dependent_type_p (TREE_TYPE (value))))
+ {
+ error ("bit-field %qD with non-integral type", value);
+ return error_mark_node;
+ }
+
if (TREE_CODE (value) == TYPE_DECL)
{
error ("cannot declare %qD to be a bit-field type", value);
+2006-10-20 Lee Millward <lee.millward@codesourcery.com>
+
+ PR c++/28053
+ * g++.dg/parse/bitfield1.C: Adjust error markers.
+ * g++.dg/parse/bitfield2.C: New test.
+
2006-10-20 Adam Nemet <anemet@caviumnetworks.com>
* gcc.dg/tree-ssa/ivopts-2.c: Match final candidates line only.
void foo(A& a)
{
- (char)a.i;
+ (char)a.i; // { dg-error "no member" }
}
--- /dev/null
+//PR c++/28053
+
+struct X {};
+
+struct A
+{
+ X x : 2; // { dg-error "non-integral type" }
+};
+struct B : A {};
+
+template <typename T>
+struct C
+{
+ T t : 3;
+};
+
+C<int> c;
+
+template <typename T>
+struct D
+{
+ T t : 3; // { dg-error "non-integral type" }
+};
+
+D<double> d; // { dg-error "instantiated" }
+
+template <typename T>
+struct E
+{
+ typedef T* U;
+ U t : 3; // { dg-error "non-integral type" }
+};
+
+E<double> e;