Files
clang-p2996/flang/test/Semantics/resolve17.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

208 lines
3.2 KiB
Fortran

! RUN: %S/test_errors.sh %s %t %f18
module m
integer :: foo
!Note: PGI, Intel, and GNU allow this; NAG and Sun do not
!ERROR: 'foo' is already declared in this scoping unit
interface foo
end interface
end module
module m2
interface s
end interface
contains
!ERROR: 's' may not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic
subroutine s
end subroutine
end module
module m3
! This is okay: s is generic and specific
interface s
procedure s2
end interface
interface s
procedure s
end interface
contains
subroutine s()
end subroutine
subroutine s2(x)
end subroutine
end module
module m4a
interface g
procedure s_real
end interface
contains
subroutine s_real(x)
end
end
module m4b
interface g
procedure s_int
end interface
contains
subroutine s_int(i)
end
end
! Generic g should merge the two use-associated ones
subroutine s4
use m4a
use m4b
call g(123)
call g(1.2)
end
module m5a
interface g
procedure s_real
end interface
contains
subroutine s_real(x)
end
end
module m5b
interface gg
procedure s_int
end interface
contains
subroutine s_int(i)
end
end
! Generic g should merge the two use-associated ones
subroutine s5
use m5a
use m5b, g => gg
call g(123)
call g(1.2)
end
module m6a
interface gg
procedure sa
end interface
contains
subroutine sa(x)
end
end
module m6b
interface gg
procedure sb
end interface
contains
subroutine sb(y)
end
end
subroutine s6
!ERROR: Generic 'g' may not have specific procedures 'sa' and 'sb' as their interfaces are not distinguishable
use m6a, g => gg
use m6b, g => gg
end
module m7a
interface g
procedure s1
end interface
contains
subroutine s1(x)
end
end
module m7b
interface g
procedure s2
end interface
contains
subroutine s2(x, y)
end
end
module m7c
interface g
procedure s3
end interface
contains
subroutine s3(x, y, z)
end
end
! Merge the three use-associated generics
subroutine s7
use m7a
use m7b
use m7c
call g(1.0)
call g(1.0, 2.0)
call g(1.0, 2.0, 3.0)
end
module m8a
interface g
procedure s1
end interface
contains
subroutine s1(x)
end
end
module m8b
interface g
procedure s2
end interface
contains
subroutine s2(x, y)
end
end
module m8c
integer :: g
end
! If merged generic conflicts with another USE, it is an error (if it is referenced)
subroutine s8
use m8a
use m8b
use m8c
!ERROR: Reference to 'g' is ambiguous
g = 1
end
module m9a
interface g
module procedure s1
module procedure g
end interface
contains
subroutine g()
end
subroutine s1(x)
integer :: x
end
end module
module m9b
use m9a
interface g
module procedure s2
end interface
contains
subroutine s2(x)
real :: x
end
end module
module m9c
interface g
module procedure g
end interface
contains
subroutine g(x)
real :: x
end
end module
! Merge use-associated generics that have the same symbol (s1)
subroutine s9
use m9a
use m9b
end
! Merge use-associate generics each with specific of same name
subroutine s9c
use m9a
!ERROR: Generic interface 'g' has ambiguous specific procedures from modules 'm9a' and 'm9c'
use m9c
end