From: Joseph Myers Date: Sun, 1 May 2005 10:44:09 +0000 (+0100) Subject: re PR c/21213 (segfault declaring a transparent union) X-Git-Tag: releases/gcc-3.4.4~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e577da2b56c36a92bbd789afc68972d7f566a45;p=thirdparty%2Fgcc.git 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: r99063 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f3f0b79cd620..3143721d4b40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-05-01 Joseph S. Myers + + PR c/21213 + * c-decl.c (finish_struct): Don't dereference NULL TYPE_FIELDS of + transparent union. + 2005-05-01 Joseph S. Myers PR c/20740 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 1481fcf89cf2..619b221063b9 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5132,7 +5132,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 ("union cannot be made transparent"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c0ac69e59d50..67bc542aa978 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-05-01 Joseph S. Myers + + PR c/21213 + * gcc.dg/transparent-union-3.c: New test. + 2005-05-01 Joseph S. Myers PR c/20740