re PR c++/57793 (ICE with bitfields in get_bit_range)

PR c++/57793
c/
	* c-decl.c (finish_struct): Check for too-large class.
cp/
	* class.c (layout_class_type): Check for too-large class.

From-SVN: r200938
This commit is contained in:
Jason Merrill 2013-07-13 19:10:17 -04:00 committed by Jason Merrill
parent 53db1bc08e
commit 26d40c3d4b
5 changed files with 43 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2013-07-13 Jason Merrill <jason@redhat.com>
PR c++/57793
* c-decl.c (finish_struct): Check for too-large class.
2013-07-04 Joern Rennecke <joern.rennecke@embecosm.com>
PR c/57821

View File

@ -7210,6 +7210,12 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
layout_type (t);
if (TYPE_SIZE_UNIT (t)
&& TREE_CODE (TYPE_SIZE_UNIT (t)) == INTEGER_CST
&& !TREE_OVERFLOW (TYPE_SIZE_UNIT (t))
&& !valid_constant_size_p (TYPE_SIZE_UNIT (t)))
error ("type %qT is too large", t);
/* Give bit-fields their proper types. */
{
tree *fieldlistp = &fieldlist;

View File

@ -1,5 +1,8 @@
2013-07-13 Jason Merrill <jason@redhat.com>
PR c++/57793
* class.c (layout_class_type): Check for too-large class.
* call.c (can_convert): Allow user-defined conversions.
(can_convert_standard): New.
* cp-tree.h: Declare it.

View File

@ -6237,6 +6237,12 @@ layout_class_type (tree t, tree *virtuals_p)
/* Let the back end lay out the type. */
finish_record_layout (rli, /*free_p=*/true);
if (TYPE_SIZE_UNIT (t)
&& TREE_CODE (TYPE_SIZE_UNIT (t)) == INTEGER_CST
&& !TREE_OVERFLOW (TYPE_SIZE_UNIT (t))
&& !valid_constant_size_p (TYPE_SIZE_UNIT (t)))
error ("type %qT is too large", t);
/* Warn about bases that can't be talked about due to ambiguity. */
warn_about_ambiguous_bases (t);

View File

@ -0,0 +1,23 @@
/* PR c++/57793 */
struct A { unsigned a : 1; unsigned b : 1; };
struct B /* { dg-error "type .B. is too large" "" { target { c++ && ilp32 } } } */
{
unsigned char c[0x40000000];
unsigned char d[0x40000ff0];
struct A e;
}; /* { dg-error "type .struct B. is too large" "" { target { c && ilp32 } } } */
void *foo (struct B *p)
{
if (p->e.a)
return (void *) 0;
p->e.b = 1;
return p->c;
}
void
bar (struct B *p)
{
foo (p);
}