1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test SELECT CASE Constraints: C1145, C1146, C1147, C1148, C1149
5 ! local variable declaration
6 character :: grade1
= 'B'
8 logical :: grade3
= .false
.
10 character (len
= 10) :: name
= 'test'
11 logical, parameter :: grade5
= .false
.
12 CHARACTER(KIND
=1), parameter :: ASCII_parm1
= 'a', ASCII_parm2
='b'
13 CHARACTER(KIND
=2), parameter :: UCS16_parm
= 'c'
14 CHARACTER(KIND
=4), parameter :: UCS32_parm
='d'
18 type (scores
) :: score
= scores(25)
19 type (scores
), parameter :: score_val
= scores(50)
48 !ERROR: SELECT CASE expression must be integer, logical, or character
56 !ERROR: SELECT CASE expression must be integer, logical, or character
66 !ERROR: CASE DEFAULT conflicts with previous cases
72 !ERROR: CASE value has type 'CHARACTER(KIND=1,LEN=1_8)' which is not compatible with the SELECT CASE expression's type 'INTEGER(4)'
78 !ERROR: CASE value has type 'INTEGER(4)' which is not compatible with the SELECT CASE expression's type 'CHARACTER(KIND=1,LEN=1_8)'
86 !ERROR: CASE value has type 'INTEGER(4)' which is not compatible with the SELECT CASE expression's type 'LOGICAL(4)'
93 !ERROR: CASE value has type 'LOGICAL(4)' which is not compatible with the SELECT CASE expression's type 'INTEGER(4)'
95 !ERROR: CASE value has type 'REAL(4)' which is not compatible with the SELECT CASE expression's type 'INTEGER(4)'
97 !ERROR: CASE value has type 'CHARACTER(KIND=1,LEN=3_8)' which is not compatible with the SELECT CASE expression's type 'INTEGER(4)'
101 select
case (ASCII_parm1
)
103 !ERROR: CASE value has type 'CHARACTER(KIND=4,LEN=1_8)' which is not compatible with the SELECT CASE expression's type 'CHARACTER(KIND=1,LEN=1_8)'
105 !ERROR: CASE value has type 'CHARACTER(KIND=2,LEN=1_8)' which is not compatible with the SELECT CASE expression's type 'CHARACTER(KIND=1,LEN=1_8)'
107 !ERROR: CASE value has type 'CHARACTER(KIND=4,LEN=6_8)' which is not compatible with the SELECT CASE expression's type 'CHARACTER(KIND=1,LEN=1_8)'
109 !ERROR: CASE value has type 'CHARACTER(KIND=2,LEN=6_8)' which is not compatible with the SELECT CASE expression's type 'CHARACTER(KIND=1,LEN=1_8)'
117 !ERROR: CASE range is not allowed for LOGICAL
125 !ERROR: CASE (.true._1) conflicts with previous cases
127 !ERROR: CASE (.false._1) conflicts with previous cases
132 !WARNING: CASE has lower bound greater than upper bound
139 !ERROR: CASE (81_4:90_4) conflicts with previous cases
141 !ERROR: CASE (:80_4) conflicts with previous cases
143 !ERROR: CASE (200_4) conflicts with previous cases
151 !ERROR: CASE (:"hh") conflicts with previous cases
153 !ERROR: CASE (:"hd") conflicts with previous cases
157 !ERROR: CASE ("hj") conflicts with previous cases
159 !ERROR: CASE ("ha") conflicts with previous cases
161 !ERROR: CASE ("hz") conflicts with previous cases
168 subroutine test_overlap
170 !OK: these cases do not overlap
177 !ERROR: CASE (:0_4) conflicts with previous cases
182 subroutine test_overflow
186 !WARNING: CASE value (128_4) overflows type (INTEGER(1)) of SELECT CASE expression
188 !WARNING: CASE value (129_4) overflows type (INTEGER(1)) of SELECT CASE expression
189 !WARNING: CASE value (130_4) overflows type (INTEGER(1)) of SELECT CASE expression
191 !WARNING: CASE value (-130_4) overflows type (INTEGER(1)) of SELECT CASE expression
192 !WARNING: CASE value (-129_4) overflows type (INTEGER(1)) of SELECT CASE expression
195 !ERROR: Must be a scalar value, but is a rank-1 array
197 !ERROR: Must be a constant value