Files
clang-p2996/flang/test/Semantics/modfile35.f90
Tim Keith 99aa87a5b5 [flang][NFC] Simplify semantics test scripts
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
2020-05-11 11:49:25 -07:00

252 lines
5.3 KiB
Fortran

! RUN: %S/test_modfile.sh %s %t %f18
module m1
type :: t1
contains
procedure, pass(x) :: p1 => f
procedure, non_overridable :: p2 => f
procedure, nopass :: p3 => f
generic :: operator(+) => p1
generic :: operator(-) => p2
generic :: operator(<) => p1
generic :: operator(.and.) => p2
end type
contains
integer(8) pure function f(x, y)
class(t1), intent(in) :: x
integer, intent(in) :: y
end
! Operators resolve to type-bound operators in t1
subroutine test1(x, y, a, b)
class(t1) :: x
integer :: y
real :: a(x + y)
real :: b(x .lt. y)
end
! Operators resolve to type-bound operators in t1, compile-time resolvable
subroutine test2(x, y, a, b)
class(t1) :: x
integer :: y
real :: a(x - y)
real :: b(x .and. y)
end
! Operators resolve to type-bound operators in t1, compile-time resolvable
subroutine test3(x, y, a)
type(t1) :: x
integer :: y
real :: a(x + y)
end
end
!Expect: m1.mod
!module m1
! type :: t1
! contains
! procedure, pass(x) :: p1 => f
! procedure, non_overridable :: p2 => f
! procedure, nopass :: p3 => f
! generic :: operator(+) => p1
! generic :: operator(-) => p2
! generic :: operator(<) => p1
! generic :: operator(.and.) => p2
! end type
!contains
! pure function f(x, y)
! class(t1), intent(in) :: x
! integer(4), intent(in) :: y
! integer(8) :: f
! end
! subroutine test1(x, y, a, b)
! class(t1) :: x
! integer(4) :: y
! real(4) :: a(1_8:x%p1(y))
! real(4) :: b(1_8:x%p1(y))
! end
! subroutine test2(x, y, a, b)
! class(t1) :: x
! integer(4) :: y
! real(4) :: a(1_8:f(x, y))
! real(4) :: b(1_8:f(x, y))
! end
! subroutine test3(x,y,a)
! type(t1) :: x
! integer(4) :: y
! real(4) :: a(1_8:f(x,y))
! end
!end
module m2
type :: t1
contains
procedure, pass(x) :: p1 => f1
generic :: operator(+) => p1
end type
type, extends(t1) :: t2
contains
procedure, pass(y) :: p2 => f2
generic :: operator(+) => p2
end type
contains
integer(8) pure function f1(x, y)
class(t1), intent(in) :: x
integer, intent(in) :: y
end
integer(8) pure function f2(x, y)
class(t1), intent(in) :: x
class(t2), intent(in) :: y
end
subroutine test1(x, y, a)
class(t1) :: x
integer :: y
real :: a(x + y)
end
! Resolve to operator in parent class
subroutine test2(x, y, a)
class(t2) :: x
integer :: y
real :: a(x + y)
end
! 2nd arg is passed object
subroutine test3(x, y, a)
class(t1) :: x
class(t2) :: y
real :: a(x + y)
end
end
!Expect: m2.mod
!module m2
! type :: t1
! contains
! procedure, pass(x) :: p1 => f1
! generic :: operator(+) => p1
! end type
! type, extends(t1) :: t2
! contains
! procedure, pass(y) :: p2 => f2
! generic :: operator(+) => p2
! end type
!contains
! pure function f1(x, y)
! class(t1), intent(in) :: x
! integer(4), intent(in) :: y
! integer(8) :: f1
! end
! pure function f2(x, y)
! class(t1), intent(in) :: x
! class(t2), intent(in) :: y
! integer(8) :: f2
! end
! subroutine test1(x, y, a)
! class(t1) :: x
! integer(4) :: y
! real(4) :: a(1_8:x%p1(y))
! end
! subroutine test2(x, y, a)
! class(t2) :: x
! integer(4) :: y
! real(4) :: a(1_8:x%p1(y))
! end
! subroutine test3(x, y, a)
! class(t1) :: x
! class(t2) :: y
! real(4) :: a(1_8:y%p2(x))
! end
!end
module m3
type :: t1
contains
procedure, pass(x) :: p1 => f1
procedure :: p3 => f3
generic :: operator(.binary.) => p1
generic :: operator(.unary.) => p3
end type
type, extends(t1) :: t2
contains
procedure, pass(y) :: p2 => f2
generic :: operator(.binary.) => p2
end type
contains
integer(8) pure function f1(x, y)
class(t1), intent(in) :: x
integer, intent(in) :: y
end
integer(8) pure function f2(x, y)
class(t1), intent(in) :: x
class(t2), intent(in) :: y
end
integer(8) pure function f3(x)
class(t1), intent(in) :: x
end
subroutine test1(x, y, a)
class(t1) :: x
integer :: y
real :: a(x .binary. y)
end
! Resolve to operator in parent class
subroutine test2(x, y, a)
class(t2) :: x
integer :: y
real :: a(x .binary. y)
end
! 2nd arg is passed object
subroutine test3(x, y, a)
class(t1) :: x
class(t2) :: y
real :: a(x .binary. y)
end
subroutine test4(x, y, a)
class(t1) :: x
class(t2) :: y
real :: a(.unary. x + .unary. y)
end
end
!Expect: m3.mod
!module m3
! type::t1
! contains
! procedure,pass(x)::p1=>f1
! procedure::p3=>f3
! generic::.binary.=>p1
! generic::.unary.=>p3
! end type
! type,extends(t1)::t2
! contains
! procedure,pass(y)::p2=>f2
! generic::.binary.=>p2
! end type
!contains
! pure function f1(x,y)
! class(t1),intent(in)::x
! integer(4),intent(in)::y
! integer(8)::f1
! end
! pure function f2(x,y)
! class(t1),intent(in)::x
! class(t2),intent(in)::y
! integer(8)::f2
! end
! pure function f3(x)
! class(t1),intent(in)::x
! integer(8)::f3
! end
! subroutine test1(x,y,a)
! class(t1)::x
! integer(4)::y
! real(4)::a(1_8:x%p1(y))
! end
! subroutine test2(x,y,a)
! class(t2)::x
! integer(4)::y
! real(4)::a(1_8:x%p1(y))
! end
! subroutine test3(x,y,a)
! class(t1)::x
! class(t2)::y
! real(4)::a(1_8:y%p2(x))
! end
! subroutine test4(x,y,a)
! class(t1)::x
! class(t2)::y
! real(4)::a(1_8:x%p3()+y%p3())
! end
!end