Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / if_construct02.f90
blobc2dc759b726face1b4717128e3fa2fffb3299cbf
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check that if constructs only accept scalar logical expressions.
3 ! TODO: expand the test to check this restriction for more types.
5 INTEGER :: I
6 LOGICAL, DIMENSION (2) :: B
8 !ERROR: Must be a scalar value, but is a rank-1 array
9 if ( B ) then
10 a = 1
11 end if
13 !ERROR: Must be a scalar value, but is a rank-1 array
14 if ( B ) then
15 a = 2
16 else
17 a = 3
18 endif
20 !ERROR: Must be a scalar value, but is a rank-1 array
21 if ( B ) then
22 a = 4
23 !ERROR: Must be a scalar value, but is a rank-1 array
24 else if( B ) then
25 a = 5
26 end if
28 !ERROR: Must be a scalar value, but is a rank-1 array
29 if ( B ) then
30 a = 6
31 !ERROR: Must be a scalar value, but is a rank-1 array
32 else if( B ) then
33 a = 7
34 !ERROR: Must be a scalar value, but is a rank-1 array
35 elseif( B ) then
36 a = 8
37 end if
39 !ERROR: Must be a scalar value, but is a rank-1 array
40 if ( B ) then
41 a = 9
42 !ERROR: Must be a scalar value, but is a rank-1 array
43 else if( B ) then
44 a = 10
45 else
46 a = 11
47 end if
49 !ERROR: Must be a scalar value, but is a rank-1 array
50 if ( B ) then
51 a = 12
52 !ERROR: Must be a scalar value, but is a rank-1 array
53 else if( B ) then
54 a = 13
55 !ERROR: Must be a scalar value, but is a rank-1 array
56 else if( B ) then
57 a = 14
58 end if
61 !ERROR: Must have LOGICAL type, but is INTEGER(4)
62 if ( I ) then
63 a = 1
64 end if
66 !ERROR: Must have LOGICAL type, but is INTEGER(4)
67 if ( I ) then
68 a = 2
69 else
70 a = 3
71 endif
73 !ERROR: Must have LOGICAL type, but is INTEGER(4)
74 if ( I ) then
75 a = 4
76 !ERROR: Must have LOGICAL type, but is INTEGER(4)
77 else if( I ) then
78 a = 5
79 end if
81 !ERROR: Must have LOGICAL type, but is INTEGER(4)
82 if ( I ) then
83 a = 6
84 !ERROR: Must have LOGICAL type, but is INTEGER(4)
85 else if( I ) then
86 a = 7
87 !ERROR: Must have LOGICAL type, but is INTEGER(4)
88 elseif( I ) then
89 a = 8
90 end if
92 !ERROR: Must have LOGICAL type, but is INTEGER(4)
93 if ( I ) then
94 a = 9
95 !ERROR: Must have LOGICAL type, but is INTEGER(4)
96 else if( I ) then
97 a = 10
98 else
99 a = 11
100 end if
102 !ERROR: Must have LOGICAL type, but is INTEGER(4)
103 if ( I ) then
104 a = 12
105 !ERROR: Must have LOGICAL type, but is INTEGER(4)
106 else if( I ) then
107 a = 13
108 !ERROR: Must have LOGICAL type, but is INTEGER(4)
109 else if( I ) then
110 a = 14
111 end if
113 !ERROR: Must have LOGICAL type, but is REAL(4)
114 if (f()) then
115 a = 15
116 end if
118 contains
119 real function f()
120 f = 1.0