re PR c++/28053 (ICE deriving from class with invalid bitfield)
PR c++/28053 * 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. Co-Authored-By: Mark Mitchell <mark@codesourcery.com> From-SVN: r117910
This commit is contained in:
parent
5d7adf7a15
commit
4c9fb8704a
@ -1,3 +1,10 @@
|
||||
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
|
||||
|
@ -946,6 +946,14 @@ grokbitfield (const cp_declarator *declarator,
|
||||
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);
|
||||
|
@ -1,3 +1,9 @@
|
||||
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.
|
||||
|
@ -7,5 +7,5 @@ struct A
|
||||
|
||||
void foo(A& a)
|
||||
{
|
||||
(char)a.i;
|
||||
(char)a.i; // { dg-error "no member" }
|
||||
}
|
||||
|
34
gcc/testsuite/g++.dg/parse/bitfield2.C
Normal file
34
gcc/testsuite/g++.dg/parse/bitfield2.C
Normal file
@ -0,0 +1,34 @@
|
||||
//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;
|
Loading…
Reference in New Issue
Block a user