c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / string_ctor_1.f90
blob9acf742a93b03fab59795d585431a79681735a3c
1 ! { dg-do run }
2 ! { dg-options "-std=legacy" }
4 ! Program to test character array constructors.
5 ! PR17144
6 subroutine test1 (n, t, u)
7 integer n
8 character(len=n) :: s(2)
9 character(len=*) :: t
10 character(len=*) :: u
12 ! A variable array constructor.
13 s = (/t, u/)
14 ! An array constructor as part of an expression.
15 if (any (s .ne. (/"Hell", "Worl"/))) STOP 1
16 end subroutine
18 subroutine test2
19 character*5 :: s(2)
21 ! A constant array constructor
22 s = (/"Hello", "World"/)
23 if ((s(1) .ne. "Hello") .or. (s(2) .ne. "World")) STOP 2
24 end subroutine
26 subroutine test3
27 character*1 s(26)
28 character*26 t
29 integer i
31 ! A large array constructor
32 s = (/'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', &
33 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'/)
34 do i=1, 26
35 t(i:i) = s(i)
36 end do
38 ! Assignment with dependency
39 s = (/(s(27-i), i=1, 26)/)
40 do i=1, 26
41 t(i:i) = s(i)
42 end do
43 if (t .ne. "zyxwvutsrqponmlkjihgfedcba") STOP 3
44 end subroutine
46 program string_ctor_1
47 call test1 (4, "Hello", "World")
48 call test2
49 call test3
50 end program