* c-decl.c (finish_struct): Don't dereference NULL TYPE_FIELDS of
transparent union.
testsuite:
* gcc.dg/transparent-union-3.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98808
138bc75d-0d04-0410-961f-
82ee72b054a4
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
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,
--- /dev/null
+/* 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 } */