Fix compilation failure with C++98 compilers
[official-gcc.git] / gcc / testsuite / gfortran.dg / pr50769.f90
bloba19d07663a79a11c44299c68915db4267b3b8ac5
1 ! { dg-do compile }
2 ! { dg-options "-O2 -ftree-tail-merge -fno-delete-null-pointer-checks -fno-guess-branch-probability" }
4 ! based on testsuite/gfortran.dg/alloc_comp_optional_1.f90,
5 ! which was contributed by David Kinniburgh <davidkinniburgh@yahoo.co.uk>
7 program test_iso
8 type ivs
9 character(LEN=1), dimension(:), allocatable :: chars
10 end type ivs
11 type(ivs) :: v_str
12 integer :: i
13 call foo(v_str, i)
14 if (v_str%chars(1) .ne. "a") STOP 1
15 if (i .ne. 0) STOP 2
16 call foo(flag = i)
17 if (i .ne. 1) STOP 3
18 contains
19 subroutine foo (arg, flag)
20 type(ivs), optional, intent(out) :: arg
21 integer :: flag
22 if (present(arg)) then
23 arg = ivs([(char(i+96), i = 1,10)])
24 flag = 0
25 else
26 flag = 1
27 end if
28 end subroutine
29 end