summaryrefslogtreecommitdiff
path: root/gcc/c-pragma.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-06-21 05:11:15 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-06-21 05:11:15 +0000
commitd93f89339e4cadcc083a5b9c81a58f1cfa5159fb (patch)
treeee92f4ae95adf9823b844a162e6c97b3635091b9 /gcc/c-pragma.c
parent189127997c880d879dbab528933351325b722cb9 (diff)
downloadgcc-d93f89339e4cadcc083a5b9c81a58f1cfa5159fb.tar.gz
* c-pragma.c (push_alignment): Don't ignore alignments greater than
4 bytes. (insert_pack_attributes): Take into account member natural alignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@27648 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-pragma.c')
-rw-r--r--gcc/c-pragma.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c
index de9cfb899e5..5aa8d9f2870 100644
--- a/gcc/c-pragma.c
+++ b/gcc/c-pragma.c
@@ -141,7 +141,7 @@ pop_alignment (id)
{
entry = alignment_stack->prev;
- if (entry == NULL || entry->alignment > 4)
+ if (entry == NULL)
maximum_field_alignment = 0;
else
maximum_field_alignment = entry->alignment * 8;
@@ -163,6 +163,7 @@ insert_pack_attributes (node, attributes, prefix)
tree * prefix;
{
tree a;
+ int field_alignment;
/* If we are not packing, then there is nothing to do. */
if (maximum_field_alignment == 0
@@ -173,12 +174,16 @@ insert_pack_attributes (node, attributes, prefix)
if (TREE_CODE_CLASS (TREE_CODE (node)) != 'd'
|| TREE_CODE (node) != FIELD_DECL)
return;
+
+ field_alignment = TYPE_ALIGN (TREE_TYPE (node));
+ if (field_alignment <= 0 || field_alignment > maximum_field_alignment)
+ field_alignment = maximum_field_alignment;
/* Add a 'packed' attribute. */
* attributes = tree_cons (get_identifier ("packed"), NULL, * attributes);
/* If the alignment is > 8 then add an alignment attribute as well. */
- if (maximum_field_alignment > 8)
+ if (field_alignment > 8)
{
/* If the aligned attribute is already present then do not override it. */
for (a = * attributes; a; a = TREE_CHAIN (a))
@@ -201,7 +206,7 @@ insert_pack_attributes (node, attributes, prefix)
* attributes = tree_cons
(get_identifier ("aligned"),
tree_cons (NULL,
- build_int_2 (maximum_field_alignment / 8, 0),
+ build_int_2 (field_alignment / 8, 0),
NULL),
* attributes);
}