[patch, fortran,committed] fix elemental_optional_args_1.f90 (Re: [Fortran, Patch] PR33231 - elemental subroutine: intent out needs an array if any actual argument is an array)

Tobias Burnus burnus@net-b.de
Tue Sep 18 17:11:00 GMT 2007


Dominique Dhumieres wrote:
> FAIL: gfortran.dg/elemental_optional_args_1.f90  -O   (test for warnings, line 37)
I now removed the line completely as I failed to come up with a proper
test case.

Below you can find an explanation why I removed the line; the patch
itself is found at the very bottom.

Tobias

 * * *

Initially the following was tested:

call foobar(A1, A2, A3) ! { dg-warning "array and OPTIONAL" }

where A1 and A2 are scalars, A3 is an OPTIONAL array; the first dummy
argument is INTENT(OUT), the others are INTENT(IN), OPTIONAL.

ELEMENTAL functions need to have conformable arrays - and scalars are
conformable to any array. Thus as A3 is an array, the whole subroutine
deals with arrays of the rank and size of A3. The problem is: If A3 is
not present, the size of the to-be-returned array is not known and thus
an error is printed.

Well, the problem is: A1 is INTENT(OUT) and may thus not be a scalar if
any of the other arguments is an array (such as A3). I thus changed the
first actual argument to an array for the last 3 calls to foobar.
However, doing so for the call quoted above, there is an non-optional
array argument and thus the size of the array to be returned is known
and consequently no warning is printed. Thus I removed now that line.

Tobias

Patch committed:

Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog     (Revision 128582)
+++ gcc/testsuite/ChangeLog     (Arbeitskopie)
@@ -1,3 +1,7 @@
+2007-09-18  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/elemental_optional_args_1.f90: Fix test.
+
 2007-09-18  Paolo Carlini  <pcarlini@suse.de>

        PR c++/33463
Index: gcc/testsuite/gfortran.dg/elemental_optional_args_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/elemental_optional_args_1.f90     (Revision 128582)
+++ gcc/testsuite/gfortran.dg/elemental_optional_args_1.f90     (Arbeitskopie)
@@ -34,7 +34,6 @@
     write(6,*) efoo(A1,A3,A2)
     write(6,*) efoo(A1,A4,A3)
 ! check an elemental subroutine
-    call foobar (A5,A2,A3) ! { dg-warning "array and OPTIONAL" }
     call foobar (A5,A2,A4)
     call foobar (A5,A4,A4)
   END SUBROUTINE



More information about the Fortran mailing list