[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Semantics / resolve69.f90
blobee3e21a6a870901247b47164131993f9c59b8f6d
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 subroutine s1()
3 ! C701 (R701) The type-param-value for a kind type parameter shall be a
4 ! constant expression.
6 ! C702 (R701) A colon shall not be used as a type-param-value except in the
7 ! declaration of an entity that has the POINTER or ALLOCATABLE attribute.
9 ! C704 (R703) In a declaration-type-spec, every type-param-value that is
10 ! not a colon or an asterisk shall be a specification expression.
11 ! Section 10.1.11 defines specification expressions
13 integer, parameter :: constVal = 1
14 integer :: nonConstVal = 1
15 !ERROR: Invalid specification expression: reference to local entity 'nonconstval'
16 character(nonConstVal) :: colonString1
17 character(len=20, kind=constVal + 1) :: constKindString
18 character(len=:, kind=constVal + 1), pointer :: constKindString1
19 !ERROR: The type parameter LEN cannot be deferred without the POINTER or ALLOCATABLE attribute
20 character(len=:, kind=constVal + 1) :: constKindString2
21 !ERROR: Must be a constant value
22 character(len=20, kind=nonConstVal) :: nonConstKindString
23 !ERROR: The type parameter LEN cannot be deferred without the POINTER or ALLOCATABLE attribute
24 character(len=:) :: deferredString
25 !ERROR: The type parameter LEN cannot be deferred without the POINTER or ALLOCATABLE attribute
26 character(:) :: colonString2
27 !OK because of the allocatable attribute
28 character(:), allocatable :: colonString3
30 !ERROR: Must have INTEGER type, but is REAL(4)
31 character(3.5) :: badParamValue
33 type derived(typeKind, typeLen)
34 integer, kind :: typeKind
35 integer, len :: typeLen
36 character(typeKind) :: kindValue
37 character(typeLen) :: lenValue
38 end type derived
40 type (derived(constVal, 3)) :: constDerivedKind
41 !ERROR: Value of kind type parameter 'typekind' (nonconstval) must be a scalar INTEGER constant
42 !ERROR: Invalid specification expression: reference to local entity 'nonconstval'
43 type (derived(nonConstVal, 3)) :: nonConstDerivedKind
45 !OK because all type-params are constants
46 type (derived(3, constVal)) :: constDerivedLen
48 !ERROR: Invalid specification expression: reference to local entity 'nonconstval'
49 type (derived(3, nonConstVal)) :: nonConstDerivedLen
50 !ERROR: The value of type parameter 'typelen' cannot be deferred without the POINTER or ALLOCATABLE attribute
51 type (derived(3, :)) :: colonDerivedLen
52 !ERROR: The value of type parameter 'typekind' cannot be deferred without the POINTER or ALLOCATABLE attribute
53 !ERROR: The value of type parameter 'typelen' cannot be deferred without the POINTER or ALLOCATABLE attribute
54 type (derived( :, :)) :: colonDerivedLen1
55 type (derived( :, :)), pointer :: colonDerivedLen2
56 type (derived(4, :)), pointer :: colonDerivedLen3
57 end subroutine s1
58 Program d5
59 Type string(maxlen)
60 Integer,Kind :: maxlen
61 Character(maxlen) :: value
62 End Type
63 Type(string(80)) line
64 line%value = 'ok'
65 Print *,Trim(line%value)
66 End Program
68 !Not errors.
69 subroutine outer
70 integer n
71 contains
72 character(n) function inner1()
73 inner1 = ''
74 end function inner1
75 function inner2()
76 real inner2(n)
77 end function inner2
78 end subroutine outer