[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / if_construct02.f90
blob03fd433f75f7f95e3fecfece9970210528ba5ece
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
2 ! REQUIRES: shell
3 ! Check that if constructs only accept scalar logical expressions.
4 ! TODO: expand the test to check this restriction for more types.
6 INTEGER :: I
7 LOGICAL, DIMENSION (2) :: B
9 !ERROR: Must be a scalar value, but is a rank-1 array
10 if ( B ) then
11 a = 1
12 end if
14 !ERROR: Must be a scalar value, but is a rank-1 array
15 if ( B ) then
16 a = 2
17 else
18 a = 3
19 endif
21 !ERROR: Must be a scalar value, but is a rank-1 array
22 if ( B ) then
23 a = 4
24 !ERROR: Must be a scalar value, but is a rank-1 array
25 else if( B ) then
26 a = 5
27 end if
29 !ERROR: Must be a scalar value, but is a rank-1 array
30 if ( B ) then
31 a = 6
32 !ERROR: Must be a scalar value, but is a rank-1 array
33 else if( B ) then
34 a = 7
35 !ERROR: Must be a scalar value, but is a rank-1 array
36 elseif( B ) then
37 a = 8
38 end if
40 !ERROR: Must be a scalar value, but is a rank-1 array
41 if ( B ) then
42 a = 9
43 !ERROR: Must be a scalar value, but is a rank-1 array
44 else if( B ) then
45 a = 10
46 else
47 a = 11
48 end if
50 !ERROR: Must be a scalar value, but is a rank-1 array
51 if ( B ) then
52 a = 12
53 !ERROR: Must be a scalar value, but is a rank-1 array
54 else if( B ) then
55 a = 13
56 !ERROR: Must be a scalar value, but is a rank-1 array
57 else if( B ) then
58 a = 14
59 end if
62 !ERROR: Must have LOGICAL type, but is INTEGER(4)
63 if ( I ) then
64 a = 1
65 end if
67 !ERROR: Must have LOGICAL type, but is INTEGER(4)
68 if ( I ) then
69 a = 2
70 else
71 a = 3
72 endif
74 !ERROR: Must have LOGICAL type, but is INTEGER(4)
75 if ( I ) then
76 a = 4
77 !ERROR: Must have LOGICAL type, but is INTEGER(4)
78 else if( I ) then
79 a = 5
80 end if
82 !ERROR: Must have LOGICAL type, but is INTEGER(4)
83 if ( I ) then
84 a = 6
85 !ERROR: Must have LOGICAL type, but is INTEGER(4)
86 else if( I ) then
87 a = 7
88 !ERROR: Must have LOGICAL type, but is INTEGER(4)
89 elseif( I ) then
90 a = 8
91 end if
93 !ERROR: Must have LOGICAL type, but is INTEGER(4)
94 if ( I ) then
95 a = 9
96 !ERROR: Must have LOGICAL type, but is INTEGER(4)
97 else if( I ) then
98 a = 10
99 else
100 a = 11
101 end if
103 !ERROR: Must have LOGICAL type, but is INTEGER(4)
104 if ( I ) then
105 a = 12
106 !ERROR: Must have LOGICAL type, but is INTEGER(4)
107 else if( I ) then
108 a = 13
109 !ERROR: Must have LOGICAL type, but is INTEGER(4)
110 else if( I ) then
111 a = 14
112 end if
114 !ERROR: Must have LOGICAL type, but is REAL(4)
115 if (f()) then
116 a = 15
117 end if
119 contains
120 real function f()
121 f = 1.0