]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/6660 (Typedeffed unnamed structs/unions do not compile with gcc-3.1)
authorJakub Jelinek <jakub@redhat.com>
Mon, 10 Jun 2002 21:53:39 +0000 (23:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 10 Jun 2002 21:53:39 +0000 (23:53 +0200)
PR c/6660
* c-decl.c (grokfield): Allow user defined types if they declare
structs or unions for unnamed fields.

* gcc.dg/20020527-1.c: New test.

From-SVN: r54468

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

index 5924df9ecc9701cdccee7493fc6f4998a74b9aad..eed9043517ff59272c41ff6e4f48872a49c09b2d 100644 (file)
@@ -1,3 +1,9 @@
+2002-06-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/6660
+       * c-decl.c (grokfield): Allow user defined types if they declare
+       structs or unions for unnamed fields.
+
 2002-06-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/6809
index a1e5870727e987b9abf2019ca4adcb631690d948..a851ed99360080e9c6a0bd4193db147b27b3d0d9 100644 (file)
@@ -5591,8 +5591,11 @@ grokfield (filename, line, declarator, declspecs, width)
     {
       /* This is an unnamed decl.  We only support unnamed
         structs/unions, so check for other things and refuse them.  */
-      if (TREE_CODE (TREE_VALUE (declspecs)) != RECORD_TYPE
-         && TREE_CODE (TREE_VALUE (declspecs)) != UNION_TYPE)
+      tree type = TREE_VALUE (declspecs);
+
+      if (TREE_CODE (type) == TYPE_DECL)
+       type = TREE_TYPE (type);
+      if (TREE_CODE (type) != RECORD_TYPE && TREE_CODE (type) != UNION_TYPE)
        {
          error ("unnamed fields of type other than struct or union are not allowed");
          return NULL_TREE;
index df64e703bf88a56ca214b1ebfd7594527e209fc8..8d054012ac36f3840384288cac0f75abb3b34259 100644 (file)
@@ -6,6 +6,8 @@
 
        * gcc.dg/20020530-1.c: New test.
 
+       * gcc.dg/20020527-1.c: New test.
+
 2002-05-29  Hans-Peter Nilsson  <hp@axis.com>
 
        * gcc.c-torture/execute/20020529-1.c: New test.