gcc/
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Mar 2009 22:33:16 +0000 (22:33 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Mar 2009 22:33:16 +0000 (22:33 +0000)
2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>

PR c/39323
* c-common.c (handle_aligned_attribute): Properly check alignment
overflow.  Use (1U << i) instead of (1 << i).

* emit-rtl.c (get_mem_align_offset): Use "unsigned int" for
align.

* expr.h (get_mem_align_offset): Updated.

* tree.h (tree_decl_common): Change align to "unsigned int" and
move it before pointer_alias_set.

gcc/ada/

2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>

PR c/39323
* gcc-interface/utils.c (create_field_decl): Use "unsigned int"
on bit_align.

gcc/testsuite/

2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>

PR c/39323
* gcc.dg/pr39323-1.c: New.
* gcc.dg/pr39323-2.c: Likewise.
* gcc.dg/pr39323-3.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145136 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils.c
gcc/c-common.c
gcc/emit-rtl.c
gcc/expr.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr39323-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr39323-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr39323-3.c [new file with mode: 0644]
gcc/tree.h

index 408250b..9ea8830 100644 (file)
@@ -1,4 +1,18 @@
 2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c/39323
+       * c-common.c (handle_aligned_attribute): Properly check alignment
+       overflow.  Use (1U << i) instead of (1 << i).
+
+       * emit-rtl.c (get_mem_align_offset): Use "unsigned int" for
+       align.
+
+       * expr.h (get_mem_align_offset): Updated.
+
+       * tree.h (tree_decl_common): Change align to "unsigned int" and
+       move it before pointer_alias_set.
+
+2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>
            Jakub Jelinek  <jakub@redhat.com>
 
        PR target/38034
index 8752b3b..97bd260 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR c/39323
+       * gcc-interface/utils.c (create_field_decl): Use "unsigned int"
+       on bit_align.
+
 2009-03-11  Olivier Hainque  <hainque@adacore.com>
 
        * gcc-interface/trans.c (gnat_to_gnu) <case N_Slice>: In range
index 7b52d90..8c5dc58 100644 (file)
@@ -1707,7 +1707,7 @@ create_field_decl (tree field_name, tree field_type, tree record_type,
      we get the alignment from the type, indicate if this is from an explicit
      user request, which prevents stor-layout from lowering it later on.  */
   {
-    int bit_align
+    unsigned int bit_align
       = (DECL_BIT_FIELD (field_decl) ? 1
         : packed && TYPE_MODE (field_type) != BLKmode ? BITS_PER_UNIT : 0);
 
index 820d859..9b066f4 100644 (file)
@@ -5976,7 +5976,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
       error ("requested alignment is not a power of 2");
       *no_add_attrs = true;
     }
-  else if (i > HOST_BITS_PER_INT - 2)
+  else if (i >= HOST_BITS_PER_INT - BITS_PER_UNIT_LOG)
     {
       error ("requested alignment is too large");
       *no_add_attrs = true;
@@ -5998,7 +5998,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
       else if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
        *type = build_variant_type_copy (*type);
 
-      TYPE_ALIGN (*type) = (1 << i) * BITS_PER_UNIT;
+      TYPE_ALIGN (*type) = (1U << i) * BITS_PER_UNIT;
       TYPE_USER_ALIGN (*type) = 1;
     }
   else if (! VAR_OR_FUNCTION_DECL_P (decl)
@@ -6008,7 +6008,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
       *no_add_attrs = true;
     }
   else if (TREE_CODE (decl) == FUNCTION_DECL
-          && DECL_ALIGN (decl) > (1 << i) * BITS_PER_UNIT)
+          && DECL_ALIGN (decl) > (1U << i) * BITS_PER_UNIT)
     {
       if (DECL_USER_ALIGN (decl))
        error ("alignment for %q+D was previously specified as %d "
@@ -6021,7 +6021,7 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
     }
   else
     {
-      DECL_ALIGN (decl) = (1 << i) * BITS_PER_UNIT;
+      DECL_ALIGN (decl) = (1U << i) * BITS_PER_UNIT;
       DECL_USER_ALIGN (decl) = 1;
     }
 
index ca03382..1f51e12 100644 (file)
@@ -1495,7 +1495,7 @@ mem_expr_equal_p (const_tree expr1, const_tree expr2)
    -1 if not known.  */
 
 int
-get_mem_align_offset (rtx mem, int align)
+get_mem_align_offset (rtx mem, unsigned int align)
 {
   tree expr;
   unsigned HOST_WIDE_INT offset;
index 216de87..7e7e088 100644 (file)
@@ -699,7 +699,7 @@ extern void set_mem_attributes_minus_bitpos (rtx, tree, int, HOST_WIDE_INT);
 /* Return OFFSET if XEXP (MEM, 0) - OFFSET is known to be ALIGN
    bits aligned for 0 <= OFFSET < ALIGN / BITS_PER_UNIT, or
    -1 if not known.  */
-extern int get_mem_align_offset (rtx, int);
+extern int get_mem_align_offset (rtx, unsigned int);
 
 /* Assemble the static constant template for function entry trampolines.  */
 extern rtx assemble_trampoline_template (void);
index 0060483..269c540 100644 (file)
@@ -1,5 +1,12 @@
 2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>
 
+       PR c/39323
+       * gcc.dg/pr39323-1.c: New.
+       * gcc.dg/pr39323-2.c: Likewise.
+       * gcc.dg/pr39323-3.c: Likewise.
+
+2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>
+
        PR target/38034
        * gcc.target/ia64/sync-1.c: New.
 
diff --git a/gcc/testsuite/gcc.dg/pr39323-1.c b/gcc/testsuite/gcc.dg/pr39323-1.c
new file mode 100644 (file)
index 0000000..2876bf3
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR c/39323 */
+/* { dg-do compile { target *-*-linux* } } */
+
+int foo __attribute__ ((aligned(1 << 29))) =  20; /* { dg-error "requested alignment is too large" } */
+typedef int __attribute__ ((aligned(1 << 29))) int29; /* { dg-error "requested alignment is too large" } */
diff --git a/gcc/testsuite/gcc.dg/pr39323-2.c b/gcc/testsuite/gcc.dg/pr39323-2.c
new file mode 100644 (file)
index 0000000..2eaa6e9
--- /dev/null
@@ -0,0 +1,6 @@
+/* PR c/39323 */
+/* { dg-do compile { target *-*-linux* } } */
+
+int bar __attribute__ ((aligned(1 << 28))) =  20;
+
+/* { dg-final { scan-assembler "\.align\[\\t \]*268435456" } } */
diff --git a/gcc/testsuite/gcc.dg/pr39323-3.c b/gcc/testsuite/gcc.dg/pr39323-3.c
new file mode 100644 (file)
index 0000000..cbfed9d
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR c/39323 */
+/* { dg-do compile { target *-*-linux* } } */
+
+typedef int __attribute__ ((aligned(1 << 28))) int28;
+int28 foo = 20;
+
+/* { dg-final { scan-assembler "\.align\[\\t \]*268435456" } } */
index e1c52e1..51fd7ec 100644 (file)
@@ -2726,10 +2726,9 @@ struct tree_decl_common GTY(())
   unsigned gimple_reg_flag : 1;
   /* In a DECL with pointer type, set if no TBAA should be done.  */
   unsigned no_tbaa_flag : 1;
-  /* Padding so that 'align' can be on a 32-bit boundary.  */
+  /* Padding so that 'off_align' can be on a 32-bit boundary.  */
   unsigned decl_common_unused : 2;
 
-  unsigned int align : 24;
   /* DECL_OFFSET_ALIGN, used only for FIELD_DECLs.  */
   unsigned int off_align : 8;
 
@@ -2738,6 +2737,9 @@ struct tree_decl_common GTY(())
   tree attributes;
   tree abstract_origin;
 
+  /* DECL_ALIGN.  It should have the same size as TYPE_ALIGN.  */
+  unsigned int align;
+
   alias_set_type pointer_alias_set;
   /* Points to a structure whose details depend on the language in use.  */
   struct lang_decl *lang_specific;