]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/17675 ([Regression w.r.t. g77] Alignment constraints not honored in...
authorPaul Brook <paul@codesourcery.com>
Sun, 16 Jan 2005 12:05:53 +0000 (12:05 +0000)
committerPaul Brook <pbrook@gcc.gnu.org>
Sun, 16 Jan 2005 12:05:53 +0000 (12:05 +0000)
2004-01-16  Paul Brook  <paul@codesourcery.com>

PR fortran/17675
* trans-common.c (translate_common): Remove duplicate function call.
(finish_equivalences): Preserve alignment when biasing offsets.
testsuite/
* gfortran.dg/common_4.f90: New test.

From-SVN: r93724

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

index ba8e5b86846cdefdbc6a03308e0e7a0695a58544..8fa62a2b7a23748858dd21e585fe2587d3fcf7dd 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-16  Paul Brook  <paul@codesourcery.com>
+
+       PR fortran/17675
+       * trans-common.c (translate_common): Remove duplicate function call.
+       (finish_equivalences): Preserve alignment when biasing offsets.
+
 2005-01-15  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de
 
        * primary.c (check_digit): Call 'ISXDIGIT' instead of assuming
index 8119cd32dd7c29741b594a8c0017d115b9e73026..ce6a8b682aa22921ea22bd4b5c7e407943f124ac 100644 (file)
@@ -803,7 +803,6 @@ translate_common (gfc_common_head *common, gfc_symbol *var_list)
                       common->name, &common->where);
 
          offset = align_segment (&align);
-         apply_segment_offset (current_segment, offset);
 
          if (offset & (max_align - 1))
            {
@@ -851,7 +850,8 @@ finish_equivalences (gfc_namespace *ns)
 {
   gfc_equiv *z, *y;
   gfc_symbol *sym;
-  HOST_WIDE_INT min_offset;
+  HOST_WIDE_INT offset;
+  unsigned HOST_WIDE_INT align;
 
   for (z = ns->equiv; z; z = z->next)
     for (y = z->eq; y; y = y->eq)
@@ -864,13 +864,13 @@ finish_equivalences (gfc_namespace *ns)
         /* All objects directly or indirectly equivalenced with this symbol.  */
         add_equivalences ();
 
-        /* Bias the offsets to to start at zero.  */
-        min_offset = -current_segment->offset;
+       /* Align the block.  */
+       offset = align_segment (&align);
 
-       /* Ensure the block is properly aligned.  */
-       min_offset += align_segment (NULL);
+       /* Ensure all offsets are positive.  */
+       offset -= current_segment->offset & ~(align - 1);
 
-       apply_segment_offset (current_segment, min_offset);
+       apply_segment_offset (current_segment, offset);
 
        /* Create the decl.  */
         create_common (NULL, current_segment);
index 7930770a93be3331a0d410a7e813b3d59b87e7b2..821cfea0393b0d9368308b28fa8dd97ea199fa1d 100644 (file)
@@ -1,3 +1,7 @@
+2004-01-16  Paul Brook  <paul@codesourcery.com>
+
+       * gfortran.dg/common_4.f90: New test.
+
 2005-01-15  Hans-Peter Nilsson  <hp@axis.com>
 
        PR rtl-optimization/19462
diff --git a/gcc/testsuite/gfortran.dg/common_4.f90 b/gcc/testsuite/gfortran.dg/common_4.f90
new file mode 100644 (file)
index 0000000..9ff2123
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do run }
+! Suppress warnings about misaligned common blocks.
+! { dg-options "-w" }
+! Check misaligned common blocks.
+program prog
+  common /block/ a, b, c
+  integer*1 a
+  integer*4 b, c
+  a = 1
+  b = HUGE(b)
+  c = 2
+  call foo
+end program
+subroutine foo
+  common /block/ a, b, c
+  integer*1 a
+  integer*4 b, c
+  if (a .ne. 1 .or. b .ne. HUGE(b) .or. c .ne. 2) call abort
+end subroutine