diff options
author | Janus Weil <janus@gcc.gnu.org> | 2008-09-22 13:45:02 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2008-09-22 13:45:02 +0200 |
commit | f613cea7fc41d8133a083ced6cc0a11b9312f110 (patch) | |
tree | 5ace57c212233d9f04bcb96b875d8137f2545d01 /gcc/fortran/trans-common.c | |
parent | 22868cbf560231317a5c82348c08d396fa29f471 (diff) | |
download | gcc-f613cea7fc41d8133a083ced6cc0a11b9312f110.zip gcc-f613cea7fc41d8133a083ced6cc0a11b9312f110.tar.gz gcc-f613cea7fc41d8133a083ced6cc0a11b9312f110.tar.bz2 |
re PR fortran/37486 (alignment of data in COMMON blocks)
2008-09-22 Janus Weil <janus@gcc.gnu.org>
PR fortran/37486
* gfortran.h (gfc_option_t): New members flag_align_commons and
warn_align_commons.
* lang.opt: New options falign-commons and Walign-commons.
* invoke.texi: Documentation for new options.
* options.c (gfc_init_options): Initialize new options.
(gfc_handle_options): Handle new options.
* trans-common.c (translate_common): Implement new options.
(gfc_trans_common): Set correct locus.
2008-09-22 Janus Weil <janus@gcc.gnu.org>
PR fortran/37486
* gfortran.dg/common_align_1.f90: New.
* gfortran.dg/warn_align_commons.f90: New.
From-SVN: r140546
Diffstat (limited to 'gcc/fortran/trans-common.c')
-rw-r--r-- | gcc/fortran/trans-common.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 9e55792..92edd20 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -1059,7 +1059,9 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) bool saw_equiv; common_segment = NULL; + offset = 0; current_offset = 0; + align = 1; max_align = 1; saw_equiv = false; @@ -1100,16 +1102,27 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) "extension to COMMON '%s' at %L", sym->name, common->name, &common->where); - offset = align_segment (&align); + if (gfc_option.flag_align_commons) + offset = align_segment (&align); if (offset & (max_align - 1)) { /* The required offset conflicts with previous alignment requirements. Insert padding immediately before this segment. */ - gfc_warning ("Padding of %d bytes required before '%s' in " - "COMMON '%s' at %L", (int)offset, s->sym->name, - common->name, &common->where); + if (gfc_option.warn_align_commons) + { + if (strcmp (common->name, BLANK_COMMON_NAME)) + gfc_warning ("Padding of %d bytes required before '%s' in " + "COMMON '%s' at %L; reorder elements or use " + "-fno-align-commons", (int)offset, + s->sym->name, common->name, &common->where); + else + gfc_warning ("Padding of %d bytes required before '%s' in " + "COMMON at %L; reorder elements or use " + "-fno-align-commons", (int)offset, + s->sym->name, &common->where); + } } else { @@ -1138,10 +1151,16 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) return; } - if (common_segment->offset != 0) + if (common_segment->offset != 0 && gfc_option.warn_align_commons) { - gfc_warning ("COMMON '%s' at %L requires %d bytes of padding at start", - common->name, &common->where, (int)common_segment->offset); + if (strcmp (common->name, BLANK_COMMON_NAME)) + gfc_warning ("COMMON '%s' at %L requires %d bytes of padding at start; " + "reorder elements or use -fno-align-commons", + common->name, &common->where, (int)common_segment->offset); + else + gfc_warning ("COMMON at %L requires %d bytes of padding at start; " + "reorder elements or use -fno-align-commons", + &common->where, (int)common_segment->offset); } create_common (common, common_segment, saw_equiv); @@ -1225,14 +1244,7 @@ gfc_trans_common (gfc_namespace *ns) if (ns->blank_common.head != NULL) { c = gfc_get_common_head (); - - /* We've lost the real location, so use the location of the - enclosing procedure. */ - if (ns->proc_name != NULL) - c->where = ns->proc_name->declared_at; - else - c->where = ns->blank_common.head->common_head->where; - + c->where = ns->blank_common.head->common_head->where; strcpy (c->name, BLANK_COMMON_NAME); translate_common (c, ns->blank_common.head); } |