This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[fortran, committed] Forward port test generic_31.f90 from the 5 branch
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Wed, 19 Aug 2015 16:53:47 +0200
- Subject: [fortran, committed] Forward port test generic_31.f90 from the 5 branch
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header dot from=mikael dot morin at sfr dot fr
- References: <55AE40B2 dot 5070307 at sfr dot fr> <CAGkQGiJt31F0jadZEhkd6MVPevus=Pab55tzgJZGOU-rAqDuTQ at mail dot gmail dot com> <55B3D68D dot 5030203 at sfr dot fr> <55C33254 dot 50508 at sfr dot fr> <CAGkQGiKcJSEPUOND-wn9DBRPBmTV_HrAMKDR7dK3SpwTjvizew at mail dot gmail dot com>
Hello,
I have forward-ported the test that justified backport of the pr66929
patch on the 5 branch:
https://gcc.gnu.org/r227010
Mikael
Index: gcc/testsuite/gfortran.dg/generic_31.f90
===================================================================
--- gcc/testsuite/gfortran.dg/generic_31.f90 (révision 0)
+++ gcc/testsuite/gfortran.dg/generic_31.f90 (révision 227010)
@@ -0,0 +1,35 @@
+! { dg-do run }
+!
+! PR fortran/66929
+! Check that the specific FIRST symbol is used for the call to FOO,
+! so that the J argument is not assumed to be present
+
+module m
+ interface foo
+ module procedure first
+ end interface foo
+contains
+ elemental function bar(j) result(r)
+ integer, intent(in), optional :: j
+ integer :: r, s(2)
+ ! We used to have NULL dereference here, in case of a missing J argument
+ s = foo(j, [3, 7])
+ r = sum(s)
+ end function bar
+ elemental function first(i, j) result(r)
+ integer, intent(in), optional :: i
+ integer, intent(in) :: j
+ integer :: r
+ if (present(i)) then
+ r = i
+ else
+ r = -5
+ end if
+ end function first
+end module m
+program p
+ use m
+ integer :: i
+ i = bar()
+ if (i /= -10) call abort
+end program p
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog (révision 227009)
+++ gcc/testsuite/ChangeLog (révision 227010)
@@ -1,3 +1,8 @@
+2015-08-19 Mikael Morin <mikael@gcc.gnu.org>
+
+ PR fortran/66929
+ * gfortran.dg/generic_31.f90: New.
+
2015-08-19 Marek Polacek <polacek@redhat.com>
PR middle-end/67133