1 ! RUN: %python %S/test_errors.py %s %flang_fc1
3 ! C701 (R701) The type-param-value for a kind type parameter shall be a
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
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
60 Integer,Kind
:: maxlen
61 Character(maxlen
) :: value
65 Print *,Trim(line
%value
)
72 character(n
) function inner1()