(decl_attribute, case A_PACKED): Check is_type first.
authorRichard Kenner <kenner@gcc.gnu.org>
Tue, 29 Aug 1995 23:15:19 +0000 (19:15 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Tue, 29 Aug 1995 23:15:19 +0000 (19:15 -0400)
(decl_attribute, case A_T_UNION): Likewise.
Don't access TYPE_FIELDS if DECL is zero.

From-SVN: r10292

gcc/c-common.c

index f2715b3..3d5d3f2 100644 (file)
@@ -328,7 +328,7 @@ decl_attributes (node, attributes, prefix_attributes)
       switch (id)
        {
        case A_PACKED:
-         if (decl == 0)
+         if (is_type)
            TYPE_PACKED (type) = 1;
          else if (TREE_CODE (decl) == FIELD_DECL)
            DECL_PACKED (decl) = 1;
@@ -380,14 +380,15 @@ decl_attributes (node, attributes, prefix_attributes)
          break;
 
        case A_T_UNION:
-         if (decl != 0 && TREE_CODE (decl) == PARM_DECL
+         if (is_type
              && TREE_CODE (type) == UNION_TYPE
-             && TYPE_MODE (type) == DECL_MODE (TYPE_FIELDS (type)))
-           DECL_TRANSPARENT_UNION (decl) = 1;
-         else if (is_type
+             && (decl == 0
+                 || TYPE_MODE (type) == DECL_MODE (TYPE_FIELDS (type))))
+           TYPE_TRANSPARENT_UNION (type) = 1;
+         else if (decl != 0 && TREE_CODE (decl) == PARM_DECL
                   && TREE_CODE (type) == UNION_TYPE
                   && TYPE_MODE (type) == DECL_MODE (TYPE_FIELDS (type)))
-           TYPE_TRANSPARENT_UNION (type) = 1;
+           DECL_TRANSPARENT_UNION (decl) = 1;
          else
            warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
          break;