There were several different ways of handling the option to f18 to find predefined modules: - test_errors.sh was created by cmake substituting FLANG_INTRINSIC_MODULES_DIR into test_errors.sh.in - some tests used the flang script which has the option built it - some tests used %f18_with_includes which was replaced by the path to f18 plus the -I option - some included -I../../include/flang in their run command To make this more consistent, change %f18 to include the -intrinsic-module-directory option and use it everywhere, including to replace %flang and %f18_with_includes. This requires changing all of the invocations of the test scripts to put %f18 at the end so that it can expand to more than one argument. This eliminates the need to generate test_errors.sh which means we don't need flang/test/Semantics/CMakeLists.txt or the %B substitution. That makes the test_errors.sh command like the others, replacing %B/test/Semantics/test_errors.sh with %S/test_errors.sh. Also remove the OPTIONS: functionality as custom options can be included in the RUN: command. And remove -I/../../include/flang as that is now always included. Differential Revision: https://reviews.llvm.org/D79634
115 lines
2.2 KiB
Fortran
115 lines
2.2 KiB
Fortran
! RUN: %S/test_errors.sh %s %t %f18
|
|
integer :: y
|
|
procedure() :: a
|
|
procedure(real) :: b
|
|
call a ! OK - can be function or subroutine
|
|
!ERROR: Cannot call subroutine 'a' like a function
|
|
c = a()
|
|
!ERROR: Cannot call function 'b' like a subroutine
|
|
call b
|
|
!ERROR: Cannot call function 'y' like a subroutine
|
|
call y
|
|
call x
|
|
!ERROR: Cannot call subroutine 'x' like a function
|
|
z = x()
|
|
end
|
|
|
|
subroutine s
|
|
!ERROR: Cannot call function 'f' like a subroutine
|
|
call f
|
|
!ERROR: Cannot call subroutine 's' like a function
|
|
i = s()
|
|
contains
|
|
function f()
|
|
end
|
|
end
|
|
|
|
subroutine s2
|
|
! subroutine vs. function is determined by use
|
|
external :: a, b
|
|
call a()
|
|
!ERROR: Cannot call subroutine 'a' like a function
|
|
x = a()
|
|
x = b()
|
|
!ERROR: Cannot call function 'b' like a subroutine
|
|
call b()
|
|
end
|
|
|
|
subroutine s3
|
|
! subroutine vs. function is determined by use, even in internal subprograms
|
|
external :: a
|
|
procedure() :: b
|
|
contains
|
|
subroutine s3a()
|
|
x = a()
|
|
call b()
|
|
end
|
|
subroutine s3b()
|
|
!ERROR: Cannot call function 'a' like a subroutine
|
|
call a()
|
|
!ERROR: Cannot call subroutine 'b' like a function
|
|
x = b()
|
|
end
|
|
end
|
|
|
|
module m
|
|
! subroutine vs. function is determined at end of specification part
|
|
external :: a
|
|
procedure() :: b
|
|
contains
|
|
subroutine s()
|
|
call a()
|
|
!ERROR: Cannot call subroutine 'b' like a function
|
|
x = b()
|
|
end
|
|
end
|
|
|
|
! Call to entity in global scope, even with IMPORT, NONE
|
|
subroutine s4
|
|
block
|
|
import, none
|
|
integer :: i
|
|
!ERROR: Use of 'm' as a procedure conflicts with its declaration
|
|
i = m()
|
|
!ERROR: Use of 'm' as a procedure conflicts with its declaration
|
|
call m()
|
|
end block
|
|
end
|
|
|
|
! Call to entity in global scope, even with IMPORT, NONE
|
|
subroutine s5
|
|
block
|
|
import, none
|
|
integer :: i
|
|
i = foo()
|
|
!ERROR: Cannot call function 'foo' like a subroutine
|
|
call foo()
|
|
end block
|
|
end
|
|
|
|
subroutine s6
|
|
call a6()
|
|
end
|
|
!ERROR: 'a6' was previously called as a subroutine
|
|
function a6()
|
|
a6 = 0.0
|
|
end
|
|
|
|
subroutine s7
|
|
x = a7()
|
|
end
|
|
!ERROR: 'a7' was previously called as a function
|
|
subroutine a7()
|
|
end
|
|
|
|
!OK: use of a8 and b8 is consistent
|
|
subroutine s8
|
|
call a8()
|
|
x = b8()
|
|
end
|
|
subroutine a8()
|
|
end
|
|
function b8()
|
|
b8 = 0.0
|
|
end
|