[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / resolve55.f90
blob1133e791fa389d4df1e6839c1563ae33ce31d84a
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Tests for C1128:
3 ! A variable-name that appears in a LOCAL or LOCAL_INIT locality-spec shall not
4 ! have the ALLOCATABLE; INTENT (IN); or OPTIONAL attribute; shall not be of
5 ! finalizable type; shall not be a nonpointer polymorphic dummy argument; and
6 ! shall not be a coarray or an assumed-size array.
8 subroutine s1()
9 ! Cannot have ALLOCATABLE variable in a locality spec
10 integer, allocatable :: k
11 !ERROR: ALLOCATABLE variable 'k' not allowed in a locality-spec
12 do concurrent(i=1:5) local(k)
13 end do
14 end subroutine s1
16 subroutine s2(arg)
17 ! Cannot have a dummy OPTIONAL in a locality spec
18 integer, optional :: arg
19 !ERROR: OPTIONAL argument 'arg' not allowed in a locality-spec
20 do concurrent(i=1:5) local(arg)
21 end do
22 end subroutine s2
24 subroutine s3(arg)
25 ! This is OK
26 real :: arg
27 do concurrent(i=1:5) local(arg)
28 end do
29 end subroutine s3
31 subroutine s4(arg)
32 ! Cannot have a dummy INTENT(IN) in a locality spec
33 real, intent(in) :: arg
34 !ERROR: INTENT IN argument 'arg' not allowed in a locality-spec
35 do concurrent(i=1:5) local(arg)
36 end do
37 end subroutine s4
39 module m
40 ! Cannot have a variable of a finalizable type in a locality spec
41 type t1
42 integer :: i
43 contains
44 final :: f
45 end type t1
46 contains
47 subroutine s5()
48 type(t1) :: var
49 !ERROR: Finalizable variable 'var' not allowed in a locality-spec
50 do concurrent(i=1:5) local(var)
51 end do
52 end subroutine s5
53 subroutine f(x)
54 type(t1) :: x
55 end subroutine f
56 end module m
58 subroutine s6
59 ! Cannot have a nonpointer polymorphic dummy argument in a locality spec
60 type :: t
61 integer :: field
62 end type t
63 contains
64 subroutine s(x, y)
65 class(t), pointer :: x
66 class(t) :: y
68 ! This is allowed
69 do concurrent(i=1:5) local(x)
70 end do
72 ! This is not allowed
73 !ERROR: Nonpointer polymorphic argument 'y' not allowed in a locality-spec
74 do concurrent(i=1:5) local(y)
75 end do
76 end subroutine s
77 end subroutine s6
79 subroutine s7()
80 ! Cannot have a coarray
81 integer, codimension[*] :: coarray_var
82 !ERROR: Coarray 'coarray_var' not allowed in a locality-spec
83 do concurrent(i=1:5) local(coarray_var)
84 end do
85 end subroutine s7
87 subroutine s8(arg)
88 ! Cannot have an assumed size array
89 integer, dimension(*) :: arg
90 !ERROR: Assumed size array 'arg' not allowed in a locality-spec
91 do concurrent(i=1:5) local(arg)
92 end do
93 end subroutine s8