2020-05-12 02:38:53 +08:00
|
|
|
! RUN: %S/test_errors.sh %s %t %f18
|
2019-03-26 15:33:03 +08:00
|
|
|
! Check that if constructs only accept scalar logical expressions.
|
|
|
|
! TODO: expand the test to check this restriction for more types.
|
|
|
|
|
|
|
|
INTEGER :: I
|
|
|
|
LOGICAL, DIMENSION (2) :: B
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( B ) then
|
|
|
|
a = 1
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( B ) then
|
|
|
|
a = 2
|
|
|
|
else
|
|
|
|
a = 3
|
|
|
|
endif
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( B ) then
|
|
|
|
a = 4
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( B ) then
|
|
|
|
a = 5
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( B ) then
|
|
|
|
a = 6
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( B ) then
|
|
|
|
a = 7
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
elseif( B ) then
|
|
|
|
a = 8
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( B ) then
|
|
|
|
a = 9
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( B ) then
|
|
|
|
a = 10
|
|
|
|
else
|
|
|
|
a = 11
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( B ) then
|
|
|
|
a = 12
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( B ) then
|
|
|
|
a = 13
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must be a scalar value, but is a rank-1 array
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( B ) then
|
|
|
|
a = 14
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( I ) then
|
|
|
|
a = 1
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( I ) then
|
|
|
|
a = 2
|
|
|
|
else
|
|
|
|
a = 3
|
|
|
|
endif
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( I ) then
|
|
|
|
a = 4
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( I ) then
|
|
|
|
a = 5
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( I ) then
|
|
|
|
a = 6
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( I ) then
|
|
|
|
a = 7
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
elseif( I ) then
|
|
|
|
a = 8
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( I ) then
|
|
|
|
a = 9
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( I ) then
|
|
|
|
a = 10
|
|
|
|
else
|
|
|
|
a = 11
|
|
|
|
end if
|
|
|
|
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
if ( I ) then
|
|
|
|
a = 12
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( I ) then
|
|
|
|
a = 13
|
2019-04-12 08:22:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is INTEGER(4)
|
2019-03-26 15:33:03 +08:00
|
|
|
else if( I ) then
|
|
|
|
a = 14
|
|
|
|
end if
|
|
|
|
|
2019-04-17 22:42:16 +08:00
|
|
|
!ERROR: Must have LOGICAL type, but is REAL(4)
|
|
|
|
if (f()) then
|
|
|
|
a = 15
|
|
|
|
end if
|
|
|
|
|
|
|
|
contains
|
|
|
|
real function f()
|
|
|
|
f = 1.0
|
|
|
|
end
|
2019-03-26 15:33:03 +08:00
|
|
|
end
|