nvptx, libgfortran: Switch out of "minimal" mode
[official-gcc.git] / gcc / testsuite / gfortran.dg / optional_absent_2.f90
bloba04e9a6df6f231b65048cdea413b893e0b4db820
1 ! { dg-do run }
3 ! PR fortran/51758
5 ! Contributed by Mikael Morin
7 ! Check whether passing NULL() to an elemental procedure works,
8 ! where NULL() denotes an absent optional argument.
10 program p
12 integer :: a(2)
13 integer :: b
15 a = 0
16 a = foo((/ 1, 1 /), null())
17 ! print *, a
18 if (any(a /= 2)) STOP 1
20 a = 0
21 a = bar((/ 1, 1 /), null())
22 ! print *, a
23 if (any(a /= 2)) STOP 2
25 b = 0
26 b = bar(1, null())
27 ! print *, b
28 if (b /= 2) STOP 3
30 contains
32 function foo(a, b)
33 integer :: a(:)
34 integer, optional :: b(:)
35 integer :: foo(size(a))
37 if (present(b)) STOP 4
39 foo = 2
40 end function foo
42 elemental function bar(a, b)
43 integer, intent(in) :: a
44 integer, intent(in), optional :: b
45 integer :: bar
47 bar = 2
49 if (present(b)) bar = 1
51 end function bar
53 end program p