aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-03-06 00:44:11 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-03-06 00:44:11 +0000
commit2f76571e54dc5e8cce9acacca3bcc78acb3dacac (patch)
tree4ca9ac28636c3b828f67acccd92d4de2ce9d47d4 /gcc/ada/decl.c
parentca9052ce17c72129b59e1e17d790a3e08737f82e (diff)
downloadgcc-2f76571e54dc5e8cce9acacca3bcc78acb3dacac.zip
gcc-2f76571e54dc5e8cce9acacca3bcc78acb3dacac.tar.gz
gcc-2f76571e54dc5e8cce9acacca3bcc78acb3dacac.tar.bz2
re PR ada/35186 (implicit assumption about alignment of DImode)
PR ada/35186 * decl.c (maybe_pad_type): Avoid padding an integral type when bumping its alignment is sufficient. From-SVN: r132963
Diffstat (limited to 'gcc/ada/decl.c')
-rw-r--r--gcc/ada/decl.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index 9945e4e..237d1a4 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -5301,7 +5301,6 @@ maybe_pad_type (tree type, tree size, unsigned int align,
off the padding, since we will either be returning the inner type
or repadding it. If no size or alignment is specified, use that of
the original padded type. */
-
if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type))
{
if ((!size
@@ -5326,7 +5325,6 @@ maybe_pad_type (tree type, tree size, unsigned int align,
is not done here (and is only valid for bitfields anyway), show the size
isn't changing. Likewise, clear the alignment if it isn't being
changed. Then return if we aren't doing anything. */
-
if (size
&& (operand_equal_p (size, orig_size, 0)
|| (TREE_CODE (orig_size) == INTEGER_CST
@@ -5339,6 +5337,19 @@ maybe_pad_type (tree type, tree size, unsigned int align,
if (align == 0 && !size)
return type;
+ /* If no size is specified and we have an integral type, and changing
+ the alignment won't change its size, return a copy of the type
+ with the specified alignment. */
+ if (!size
+ && INTEGRAL_TYPE_P (type)
+ && host_integerp (orig_size, 1)
+ && (TREE_INT_CST_LOW (orig_size) % align) == 0)
+ {
+ type = copy_type (type);
+ TYPE_ALIGN (type) = align;
+ return type;
+ }
+
/* We used to modify the record in place in some cases, but that could
generate incorrect debugging information. So make a new record
type and name. */