aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-common.c
diff options
context:
space:
mode:
authorChristopher D. Rickett <crickett@lanl.gov>2007-11-24 05:42:07 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2007-11-24 05:42:07 +0000
commitaf90c10fe1738861ec3b9be24a13e8215905c6e2 (patch)
treec5a64ccde3c654fc170b739328b5f5ab27f8e278 /gcc/fortran/trans-common.c
parentb769ac9cb87157122d3aae1086d41566575a15b0 (diff)
downloadgcc-af90c10fe1738861ec3b9be24a13e8215905c6e2.zip
gcc-af90c10fe1738861ec3b9be24a13e8215905c6e2.tar.gz
gcc-af90c10fe1738861ec3b9be24a13e8215905c6e2.tar.bz2
trans-common.c (build_common_decl): Fix the alignment for BIND(C) common blocks.
2007-11-23 Christopher D. Rickett <crickett@lanl.gov> * trans-common.c (build_common_decl): Fix the alignment for BIND(C) common blocks. From-SVN: r130393
Diffstat (limited to 'gcc/fortran/trans-common.c')
-rw-r--r--gcc/fortran/trans-common.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 6040782..64cee0d 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -407,7 +407,20 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
SET_DECL_ASSEMBLER_NAME (decl, gfc_sym_mangled_common_id (com));
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
- DECL_ALIGN (decl) = BIGGEST_ALIGNMENT;
+ if (!com->is_bind_c)
+ DECL_ALIGN (decl) = BIGGEST_ALIGNMENT;
+ else
+ {
+ /* Do not set the alignment for bind(c) common blocks to
+ BIGGEST_ALIGNMENT because that won't match what C does. Also,
+ for common blocks with one element, the alignment must be
+ that of the field within the common block in order to match
+ what C will do. */
+ tree field = NULL_TREE;
+ field = TYPE_FIELDS (TREE_TYPE (decl));
+ if (TREE_CHAIN (field) == NULL_TREE)
+ DECL_ALIGN (decl) = TYPE_ALIGN (TREE_TYPE (field));
+ }
DECL_USER_ALIGN (decl) = 0;
GFC_DECL_COMMON_OR_EQUIV (decl) = 1;