aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2009-03-07 16:32:34 +0000
committerH.J. Lu <hongjiu.lu@intel.com>2009-03-07 16:32:34 +0000
commitbf3a34e04b750f66620534d34754029e472c490e (patch)
treeddb944127dba9dc80dda8f1c2bf672571235f4df
parenta239806d2851d48aec609f6c32fd85677b12914b (diff)
gcc/stack
2009-03-07 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-07 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-07 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: https://gcc.gnu.org/svn/gcc/branches/stack@144701 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.stackalign14
-rw-r--r--gcc/ada/ChangeLog.stackalign5
-rw-r--r--gcc/ada/gcc-interface/utils.c2
-rw-r--r--gcc/c-common.c8
-rw-r--r--gcc/emit-rtl.c2
-rw-r--r--gcc/expr.h2
-rw-r--r--gcc/testsuite/ChangeLog.stackalign7
-rw-r--r--gcc/testsuite/gcc.dg/pr39323-1.c5
-rw-r--r--gcc/testsuite/gcc.dg/pr39323-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/pr39323-3.c7
-rw-r--r--gcc/tree.h6
11 files changed, 55 insertions, 9 deletions
diff --git a/gcc/ChangeLog.stackalign b/gcc/ChangeLog.stackalign
index 4a59075172c..fba90ef6b98 100644
--- a/gcc/ChangeLog.stackalign
+++ b/gcc/ChangeLog.stackalign
@@ -1,3 +1,17 @@
+2009-03-07 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-02-28 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/39315
diff --git a/gcc/ada/ChangeLog.stackalign b/gcc/ada/ChangeLog.stackalign
new file mode 100644
index 00000000000..e90a34d3bd5
--- /dev/null
+++ b/gcc/ada/ChangeLog.stackalign
@@ -0,0 +1,5 @@
+2009-03-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR c/39323
+ * gcc-interface/utils.c (create_field_decl): Use "unsigned int"
+ on bit_align.
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 7b52d902241..8c5dc583625 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -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);
diff --git a/gcc/c-common.c b/gcc/c-common.c
index a84113f867e..0a8d99e5a85 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5931,7 +5931,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;
@@ -5953,7 +5953,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)
@@ -5963,7 +5963,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 "
@@ -5976,7 +5976,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;
}
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index ca033824c0d..1f51e125f35 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -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;
diff --git a/gcc/expr.h b/gcc/expr.h
index 730f8052692..cfda3a79788 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -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);
diff --git a/gcc/testsuite/ChangeLog.stackalign b/gcc/testsuite/ChangeLog.stackalign
index 70bd2582d43..9669285f141 100644
--- a/gcc/testsuite/ChangeLog.stackalign
+++ b/gcc/testsuite/ChangeLog.stackalign
@@ -1,3 +1,10 @@
+2009-03-07 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-03 Joey Ye <joey.ye@intel.com>
H.J. Lu <hongjiu.lu@intel.com>
diff --git a/gcc/testsuite/gcc.dg/pr39323-1.c b/gcc/testsuite/gcc.dg/pr39323-1.c
new file mode 100644
index 00000000000..2876bf39aba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr39323-1.c
@@ -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
index 00000000000..2eaa6e96e73
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr39323-2.c
@@ -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
index 00000000000..cbfed9dbcef
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr39323-3.c
@@ -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" } } */
diff --git a/gcc/tree.h b/gcc/tree.h
index 1f70e0461ea..3d8dc17385e 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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;