]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/21213 (segfault declaring a transparent union)
authorJoseph Myers <joseph@codesourcery.com>
Sun, 1 May 2005 10:44:09 +0000 (11:44 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Sun, 1 May 2005 10:44:09 +0000 (11:44 +0100)
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

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog

index f3f0b79cd6206d217988be767d1ca255e62f7286..3143721d4b40ff222fe865b7d1495fd0c2f6aa4e 100644 (file)
@@ -1,3 +1,9 @@
+2005-05-01  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/21213
+       * c-decl.c (finish_struct): Don't dereference NULL TYPE_FIELDS of
+       transparent union.
+
 2005-05-01  Joseph S. Myers  <joseph@codesourcery.com>
 
        PR c/20740
index 1481fcf89cf22e1919bd6f8c15dad4ff3db7376a..619b221063b9f710e7a23b0701250acbab5cb016 100644 (file)
@@ -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");
index c0ac69e59d50de0e491eeea6f1f6dad5350e9504..67bc542aa9784634e2874bc3d1c70f49a7412005 100644 (file)
@@ -1,3 +1,8 @@
+2005-05-01  Joseph S. Myers  <joseph@codesourcery.com>
+
+       PR c/21213
+       * gcc.dg/transparent-union-3.c: New test.
+
 2005-05-01  Joseph S. Myers  <joseph@codesourcery.com>
 
        PR c/20740