From: Tobias Burnus Date: Tue, 11 Oct 2011 12:33:22 +0000 (+0200) Subject: re PR fortran/50273 (-Walign-commons no longer effective) X-Git-Tag: releases/gcc-4.5.4~408 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e70ddb1c61a23dd6ab1e833ae43943ec4ad64f4;p=thirdparty%2Fgcc.git re PR fortran/50273 (-Walign-commons no longer effective) 2011-10-11 Tobias Burnus PR fortran/50273 * trans-common.c (translate_common): Fix -Walign-commons check. 2011-10-11 Tobias Burnus PR fortran/50273 * gfortran.dg/common_16.f90: New. From-SVN: r179800 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c823d1828b96..1dc6dd8e0ea2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2011-10-11 Tobias Burnus + + PR fortran/50273 + * trans-common.c (translate_common): Fix -Walign-commons check. + 2011-09-01 Mikael Morin PR fortran/50050 diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 21abde3397d9..2ea62f570791 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -1060,14 +1060,12 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) HOST_WIDE_INT offset; HOST_WIDE_INT current_offset; unsigned HOST_WIDE_INT align; - unsigned HOST_WIDE_INT max_align; bool saw_equiv; common_segment = NULL; offset = 0; current_offset = 0; align = 1; - max_align = 1; saw_equiv = false; /* Add symbols to the segment. */ @@ -1110,7 +1108,7 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) if (gfc_option.flag_align_commons) offset = align_segment (&align); - if (offset & (max_align - 1)) + if (offset) { /* The required offset conflicts with previous alignment requirements. Insert padding immediately before this @@ -1133,8 +1131,6 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) /* Apply the offset to the new segments. */ apply_segment_offset (current_segment, offset); current_offset += offset; - if (max_align < align) - max_align = align; /* Add the new segments to the common block. */ common_segment = add_segments (common_segment, current_segment); @@ -1154,11 +1150,11 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list) if (common_segment->offset != 0 && gfc_option.warn_align_commons) { if (strcmp (common->name, BLANK_COMMON_NAME)) - gfc_warning ("COMMON '%s' at %L requires %d bytes of padding at start; " + gfc_warning ("COMMON '%s' at %L requires %d bytes of padding; " "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; " + gfc_warning ("COMMON at %L requires %d bytes of padding; " "reorder elements or use -fno-align-commons", &common->where, (int)common_segment->offset); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e2ee186b238..0f1c6907de41 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-10-11 Tobias Burnus + + PR fortran/50273 + * gfortran.dg/common_16.f90: New. + 2011-09-22 Uros Bizjak PR target/50464 diff --git a/gcc/testsuite/gfortran.dg/common_16.f90 b/gcc/testsuite/gfortran.dg/common_16.f90 new file mode 100644 index 000000000000..3314e80ef9dd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_16.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-pedantic -mdalign" { target sh*-*-* } } +! +! PR fortran/50273 +! +subroutine test() + character :: a + integer :: b + character :: c + common /global_var/ a, b, c ! { dg-warning "Padding of 3 bytes required before 'b' in COMMON" } + print *, a, b, c +end subroutine test