diff mbox series

[fortran] Fix contiguous dummy arguments

Message ID fc5fc0c8-9245-365d-dd55-c150a93773cd@netcologne.de
State New
Headers show
Series [fortran] Fix contiguous dummy arguments | expand

Commit Message

Thomas Koenig Jan. 19, 2019, 3:05 p.m. UTC
Hello world,

the attached patch fixes handling of contiguous dummy arguments when
the actual arguments are not contiguous.

The patch to trans-expr.c itself was written by Paul and attached to
the PR. I just added the test case.  Regression-testing revealed some
failing scan-tree tests due to different code being generated. I put
corresponding run time tests into the new test case to make sure that no
wrong code is being generated.

I have also tested the new test case and the compiler with valgrind.

OK for trunk?

Regards

	Thomas

2018-01-19  Thomas Koenig  <tkoenig@gcc.gnu.org>
         Paul Thomas  <pault@gcc.gnu.org>

         PR fortran/56789
         * trans-expr.c (gfc_conv_procedure_call): Call
         gfc_conv_subref_array_arg if the formal arg is contiguous
         and the actual arg may not be.

2018-01-19  Thomas Koenig  <tkoenig@gcc.gnu.org>
         Paul Thomas  <pault@gcc.gnu.org>

         PR fortran/56789
         * gfortran.dg/contiguous_3.f90: Make code compilant.  Remove
         scan-tree tests that fail with patch.
         * gfortran.dg/contiguous_8.f90: New test.

Comments

Jerry DeLisle Jan. 19, 2019, 6 p.m. UTC | #1
On 1/19/19 7:05 AM, Thomas Koenig wrote:
> Hello world,
> 
> the attached patch fixes handling of contiguous dummy arguments when
> the actual arguments are not contiguous.
> 
> The patch to trans-expr.c itself was written by Paul and attached to
> the PR. I just added the test case.  Regression-testing revealed some
> failing scan-tree tests due to different code being generated. I put
> corresponding run time tests into the new test case to make sure that no
> wrong code is being generated.
> 
> I have also tested the new test case and the compiler with valgrind.
> 
> OK for trunk?
> 

Looks OK

Jerry
diff mbox series

Patch

Index: fortran/trans-expr.c
===================================================================
--- fortran/trans-expr.c	(Revision 267903)
+++ fortran/trans-expr.c	(Arbeitskopie)
@@ -5819,6 +5819,13 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
 					     INTENT_IN,
 					     fsym && fsym->attr.pointer);
 		}
+	      else if (fsym && fsym->attr.contiguous
+		       && !gfc_is_simply_contiguous (e, false, true))
+		{
+		  gfc_conv_subref_array_arg (&parmse, e, nodesc_arg,
+				fsym ? fsym->attr.intent : INTENT_INOUT,
+				fsym && fsym->attr.pointer);
+		}
 	      else
 		gfc_conv_array_parameter (&parmse, e, nodesc_arg, fsym,
 					  sym->name, NULL);
Index: testsuite/gfortran.dg/contiguous_3.f90
===================================================================
--- testsuite/gfortran.dg/contiguous_3.f90	(Revision 267903)
+++ testsuite/gfortran.dg/contiguous_3.f90	(Arbeitskopie)
@@ -8,6 +8,8 @@ 
 
 subroutine test1(a,b)
   integer, pointer, contiguous :: test1_a(:)
+  integer, target, dimension(3) :: aa
+  test1_a => aa
   call foo(test1_a)
   call foo(test1_a(::1))
   call foo(test1_a(::2))
@@ -56,9 +58,3 @@  contains
   end subroutine bar
 end subroutine test3
 
-! Once for test1 (third call), once for test3 (second call)
-! { dg-final { scan-tree-dump-times "data = origptr" 1 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_internal_pack .&parm" 2 "original" } }
-! { dg-final { scan-tree-dump-times "_gfortran_internal_unpack .&parm" 2 "original" } }
-
-