From: Mikael Morin Date: Wed, 19 Aug 2015 14:47:23 +0000 (+0000) Subject: Forward-port test generic_31.f90 from the 5 branch. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea0daf5f374f765891ab8ab9e6652bdf9746d34c;p=gcc.git Forward-port test generic_31.f90 from the 5 branch. gcc/testsuite/ PR fortran/66929 * gfortran.dg/generic_31.f90: New. From-SVN: r227010 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e04bb1bc62d..e162dd26d78 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-08-19 Mikael Morin + + PR fortran/66929 + * gfortran.dg/generic_31.f90: New. + 2015-08-19 Marek Polacek PR middle-end/67133 diff --git a/gcc/testsuite/gfortran.dg/generic_31.f90 b/gcc/testsuite/gfortran.dg/generic_31.f90 new file mode 100644 index 00000000000..2c0d0299005 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/generic_31.f90 @@ -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