]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/18282 (PR c/17384 patch causes regression from 3.4.2)
authorRichard Henderson <rth@redhat.com>
Fri, 10 Dec 2004 19:23:25 +0000 (11:23 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 10 Dec 2004 19:23:25 +0000 (11:23 -0800)
        PR c/18282
        * attribs.c (decl_attributes): Clear DECL_ALIGN when relaying out decl.
        * c-common.c (handle_mode_attribute): Handle enumeral types.

From-SVN: r92004

gcc/ChangeLog
gcc/attribs.c
gcc/c-common.c

index d544e3102f77c6fdc4b1829e47a0c32288df96f3..90c36d9644d46e04afb35e70a4996f56d6599162 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-09  Richard Henderson  <rth@redhat.com>
+
+       PR c/18282
+       * attribs.c (decl_attributes): Clear DECL_ALIGN when relaying out decl.
+       * c-common.c (handle_mode_attribute): Handle enumeral types.
+
 2004-12-09  Richard Henderson  <rth@redhat.com>
 
        PR target/17025
index a40fea7e76109217822ca1ed692a16320d60100a..3286bf309dfa4aeb3d198d60fe43438f1fad083f 100644 (file)
@@ -266,6 +266,8 @@ decl_attributes (tree *node, tree attributes, int flags)
          /* Force a recalculation of mode and size.  */
          DECL_MODE (*node) = VOIDmode;
          DECL_SIZE (*node) = 0;
+         if (!DECL_USER_ALIGN (*node))
+           DECL_ALIGN (*node) = 0;
 
          layout_decl (*node, 0);
        }
index dd3cec9bef25e4af056bcef515f9f91445d4ec9a..29dc28ec6fba53465da07462497a708ef7036d0c 100644 (file)
@@ -4678,6 +4678,32 @@ handle_mode_attribute (tree *node, tree name, tree args ATTRIBUTE_UNUSED,
                                                        mode);
              *node = ptr_type;
            }
+         else if (TREE_CODE (type) == ENUMERAL_TYPE)
+           {
+             /* For enumeral types, copy the precision from the integer
+                type returned above.  If not an INTEGER_TYPE, we can't use
+                this mode for this type.  */
+             if (TREE_CODE (typefm) != INTEGER_TYPE)
+               {
+                 error ("cannot use mode %qs for enumeral types", p);
+                 return NULL_TREE;
+               }
+
+             if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+               type = build_type_copy (type);
+
+             /* We cannot use layout_type here, because that will attempt
+                to re-layout all variants, corrupting our original.  */
+             TYPE_PRECISION (type) = TYPE_PRECISION (typefm);
+             TYPE_MIN_VALUE (type) = TYPE_MIN_VALUE (typefm);
+             TYPE_MAX_VALUE (type) = TYPE_MAX_VALUE (typefm);
+             TYPE_SIZE (type) = TYPE_SIZE (typefm);
+             TYPE_SIZE_UNIT (type) = TYPE_SIZE_UNIT (typefm);
+             if (!TYPE_USER_ALIGN (type))
+               TYPE_ALIGN (type) = TYPE_ALIGN (typefm);
+
+             *node = type;
+           }
          else if (VECTOR_MODE_P (mode)
                   ? TREE_CODE (type) != TREE_CODE (TREE_TYPE (typefm))
                   : TREE_CODE (type) != TREE_CODE (typefm))