Commit eb3490b9 by Joseph Myers Committed by Joseph Myers

re PR c/21213 (segfault declaring a transparent union)

	PR c/21213
	* c-decl.c (finish_struct): Don't dereference NULL TYPE_FIELDS of
	transparent union.

testsuite:
	* gcc.dg/transparent-union-3.c: New test.

From-SVN: r98808
parent 968744fc
2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
PR c/21213
* c-decl.c (finish_struct): Don't dereference NULL TYPE_FIELDS of
transparent union.
2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
PR c/20740
* c-format.c (init_dynamic_asm_fprintf_info): Give errors, not
assertion failures, if __gcc_host_wide_int__ is not properly
......
......@@ -5329,7 +5329,7 @@ finish_struct (tree t, tree fieldlist, tree attributes)
make it one, warn and turn off the flag. */
if (TREE_CODE (t) == UNION_TYPE
&& TYPE_TRANSPARENT_UNION (t)
&& TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t)))
&& (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
{
TYPE_TRANSPARENT_UNION (t) = 0;
warning (0, "union cannot be made transparent");
......
2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
PR c/21213
* gcc.dg/transparent-union-3.c: New test.
2005-04-27 Joseph S. Myers <joseph@codesourcery.com>
PR c/20740
* gcc.dg/format/asm_fprintf-2.c, gcc.dg/format/asm_fprintf-3.c,
gcc.dg/format/asm_fprintf-4.c, gcc.dg/format/asm_fprintf-5.c,
......
/* Test for ICEs on invalid transparent unions (empty or no named
members). Bug 21213. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "" } */
enum e { A };
union __attribute__((__transparent_union__)) ue1 { enum e; }; /* { dg-warning "warning: declaration does not declare anything" } */
/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 9 } */
union ue2 { enum e; } __attribute__((__transparent_union__)); /* { dg-warning "warning: declaration does not declare anything" } */
/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 11 } */
union __attribute__((__transparent_union__)) ui1 { int; }; /* { dg-warning "warning: declaration does not declare anything" } */
/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 14 } */
union ui2 { int; } __attribute__((__transparent_union__)); /* { dg-warning "warning: declaration does not declare anything" } */
/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 16 } */
union __attribute__((__transparent_union__)) u1 { };
/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 19 } */
union u2 { } __attribute__((__transparent_union__));
/* { dg-warning "warning: union cannot be made transparent" "" { target *-*-* } 21 } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment