Debian Codegraph @

gcc/testsuite/gfortran.dg/missing_optional_dummy_3.f90

raw
1 ! { dg-do compile }
2 ! Tests the fix for PR29976, in which the call to CMPLX caused an
3 ! ICE with an optional dummy for the imaginary part.
4 !
5 ! Contributed by Francois-Xavier Coudert <[email protected]>
6 !
7 SUBROUTINE pw_sumup (alpha_im)
8 REAL, INTENT(in), OPTIONAL :: alpha_im
9 COMPLEX :: my_alpha_c
10 IF (PRESENT(alpha_im)) THEN
11 my_alpha_c = CMPLX(0.,alpha_im)
12 END IF
13 END SUBROUTINE pw_sumup
14
15 ! Check non-intrinsic functions.
16 SUBROUTINE pw_sumup_2 (alpha_im)
17 REAL, INTENT(in), OPTIONAL :: alpha_im
18 COMPLEX :: my_alpha_c
19 IF (PRESENT(alpha_im)) THEN
20 my_alpha_c = MY_CMPLX(0.,alpha_im)
21 END IF
22 contains
23 complex function MY_CMPLX (re, im)
24 real, intent(in) :: re
25 real, intent(in), optional :: im
26 if (present (im)) then
27 MY_CMPLX = cmplx (re, im)
28 else
29 MY_CMPLX = cmplx (re, 0.0)
30 end if
31 end function MY_CMPLX
32 END SUBROUTINE pw_sumup_2