]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/45044 (Different named COMMON block size: No warning)
authorTobias Burnus <burnus@net-b.de>
Sun, 9 Oct 2011 19:37:47 +0000 (21:37 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Sun, 9 Oct 2011 19:37:47 +0000 (21:37 +0200)
2011-10-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/45044
        * trans-common.c (translate_common): Fix -Walign-commons
        check.

2011-10-09  Tobias Burnus  <burnus@net-b.de>

        PR fortran/45044
        * gfortran.dg/common_14.f90: Compile with -Wno-align-commons.
        * gfortran.dg/common_16.f90: New.

From-SVN: r179729

gcc/fortran/ChangeLog
gcc/fortran/trans-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/common_14.f90
gcc/testsuite/gfortran.dg/common_16.f90 [new file with mode: 0644]

index a8b999297886b8da2f737b4f1153bcc967edfb70..2156e716bdbc65e5675b385696c9ebe5d457804c 100644 (file)
@@ -1,3 +1,8 @@
+2011-10-09  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/45044
+       * trans-common.c (translate_common): Fix -Walign-commons check.
+
 2011-10-09  Mikael Morin  <mikael.morin@sfr.fr>
 
        * interface.c (check_dummy_characteristics): Count dimensions starting
index 21237c8d8eca0fbd86b64ea51845ee54bcd09c77..61ce44ba37adc09d7d96a9519f56c6fdbe3f6c78 100644 (file)
@@ -1067,14 +1067,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.  */
@@ -1117,7 +1115,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
@@ -1140,8 +1138,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);
@@ -1161,11 +1157,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);
     }
index c5717feed4c31047d5042d37f6e52b49204cb1fd..bef6c34335be869d5fc306ed4b55a710c72a7641 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-09  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/45044
+       * gfortran.dg/common_14.f90: Compile with -Wno-align-commons.
+       * gfortran.dg/common_16.f90: New.
+
 2011-10-09  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.dg/iso_c_binding_param_1.f90: New.
index aced168c6550bf632e50264dbf6c487ea5023c19..892e4a5705f30cd9538e00d72d30ff6513ca7a65 100644 (file)
@@ -1,4 +1,5 @@
 ! { dg-do compile }
+! { dg-options "-Wno-align-commons" }
 !
 ! PR fortran/45044
 !
diff --git a/gcc/testsuite/gfortran.dg/common_16.f90 b/gcc/testsuite/gfortran.dg/common_16.f90
new file mode 100644 (file)
index 0000000..3314e80
--- /dev/null
@@ -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