llvm-project/flang/test/Semantics/resolve54.f90

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

187 lines
3.8 KiB
Fortran
Raw Normal View History

! RUN: %S/test_errors.sh %s %t %f18
[flang] Merge pull request flang-compiler/f18#539 from flang-compiler/tsk1 Check that procedures of a generic are distinguishable Original-commit: flang-compiler/f18@a24701e313019dbf84179b79e234f92d61de0fa6 Reviewed-on: https://github.com/flang-compiler/f18/pull/539 Due to a conflicting rebase during the linearizing of flang-compiler/f18, this commit squashes a number of other commits: flang-compiler/f18@9b1343af36bd27b110f31dab39c3a18a657a5760 Some cleanup in characteristics.{h,cc} flang-compiler/f18@ddb70e53d2b4e2bba12686e4ac3c26052758fcc3 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1 flang-compiler/f18@d1eef9506610a427f992180f6b59cafe09abb9b9 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1 flang-compiler/f18@24a6d3ffbf4d26d92222b27faa155bb5b3f517f4 Make test_folding.sh stricter in test for warnings flang-compiler/f18@c2c5b640604acceb45823de8cb5716d6921da7d4 Replace SymbolList with SymbolVector flang-compiler/f18@c8499584dff12381c2ce6d4718761cd225b4d97a Add CopyAttrs to copy attributes from Symbol flang-compiler/f18@0573ffd8b2ed5757e06a4fc6d5ffc4401e800c32 Replace cascading detailsIf calls with std::visit flang-compiler/f18@28ec62b3ffeec1d25fde330069b050655bb52a5d Add name to characteristics::DummyArgument flang-compiler/f18@568eaf01145d4ee979423d06f2a65d07222f6841 Add name to CopySymbol() flang-compiler/f18@8c557b09e752da205cd300f63b5ca69806fb2e78 Check that procedures of a generic are distinguishable flang-compiler/f18@50515fd987fd5479567e1b497f6ba93974ffde76 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1 flang-compiler/f18@a7963e98a4aedc97784b99903d04cdc48fd4c346 Address review comments flang-compiler/f18@edd65b3962dbaa1121c166d47c90730e39c25a04 Merge branch 'master' of github.com:flang-compiler/f18 into tsk1
2019-07-03 05:00:44 +08:00
! Tests based on examples in C.10.6
! C.10.6(10)
module m1
interface GOOD1
function F1A(X)
real :: F1A, X
end function
function F1B(X)
integer :: F1B, X
end function
end interface
end
! C.10.6(13)
module m2
interface GOOD2
function F2A(X)
real :: F2A, X
end function
function F2B(X, Y)
complex :: F2B
real :: X, Y
end function
end interface
end
! C.10.6(15)
module m3
interface GOOD3
subroutine S3A(W, X, Y, Z)
real :: W, Y
integer :: X, Z
end subroutine
subroutine S3B(X, W, Z, Y)
real :: W, Z
integer :: X, Y
end subroutine
end interface
end
module m3b
interface GOOD3
subroutine S3B(X, W, Z, Y)
real :: W, Z
integer :: X, Y
end subroutine
subroutine S3A(W, X, Y, Z)
real :: W, Y
integer :: X, Z
end subroutine
end interface
end
! C.10.6(17)
! BAD4(1.0,2,Y=3.0,Z=4) could apply to either procedure
module m4
!ERROR: Generic 'bad4' may not have specific procedures 's4a' and 's4b' as their interfaces are not distinguishable
interface BAD4
subroutine S4A(W, X, Y, Z)
real :: W, Y
integer :: X, Z
end subroutine
subroutine S4B(X, W, Z, Y)
real :: X, Y
integer :: W, Z
end subroutine
end interface
end
module m4b
!ERROR: Generic 'bad4' may not have specific procedures 's4b' and 's4a' as their interfaces are not distinguishable
interface BAD4
subroutine S4B(X, W, Z, Y)
real :: X, Y
integer :: W, Z
end subroutine
subroutine S4A(W, X, Y, Z)
real :: W, Y
integer :: X, Z
end subroutine
end interface
end
! C.10.6(19)
module m5
interface GOOD5
subroutine S5A(X)
real :: X
end subroutine
subroutine S5B(Y, X)
real :: Y, X
end subroutine
end interface
end
module FRUITS
type :: FRUIT
end type
type, extends(FRUIT) :: APPLE
end type
type, extends(FRUIT) :: PEAR
end type
type, extends(PEAR) :: BOSC
end type
end
! C.10.6(21)
! type(PEAR) :: A_PEAR
! type(BOSC) :: A_BOSC
! BAD6(A_PEAR,A_BOSC) ! could be s6a or s6b
module m6
!ERROR: Generic 'bad6' may not have specific procedures 's6a' and 's6b' as their interfaces are not distinguishable
interface BAD6
subroutine S6A(X, Y)
use FRUITS
class(PEAR) :: X, Y
end subroutine
subroutine S6B(X, Y)
use FRUITS
class(FRUIT) :: X
class(BOSC) :: Y
end subroutine
end interface
end
module m6b
!ERROR: Generic 'bad6' may not have specific procedures 's6b' and 's6a' as their interfaces are not distinguishable
interface BAD6
subroutine S6B(X, Y)
use FRUITS
class(FRUIT) :: X
class(BOSC) :: Y
end subroutine
subroutine S6A(X, Y)
use FRUITS
class(PEAR) :: X, Y
end subroutine
end interface
end
! C.10.6(22)
module m7
interface GOOD7
subroutine S7A(X, Y, Z)
use FRUITS
class(PEAR) :: X, Y, Z
end subroutine
subroutine S7B(X, Z, W)
use FRUITS
class(FRUIT) :: X
class(BOSC) :: Z
class(APPLE), optional :: W
end subroutine
end interface
end
module m7b
interface GOOD7
subroutine S7B(X, Z, W)
use FRUITS
class(FRUIT) :: X
class(BOSC) :: Z
class(APPLE), optional :: W
end subroutine
subroutine S7A(X, Y, Z)
use FRUITS
class(PEAR) :: X, Y, Z
end subroutine
end interface
end
! C.10.6(25)
! Invalid generic (according to the rules), despite the fact that it is unambiguous
module m8
!ERROR: Generic 'bad8' may not have specific procedures 's8a' and 's8b' as their interfaces are not distinguishable
interface BAD8
subroutine S8A(X, Y, Z)
real, optional :: X
integer :: Y
real :: Z
end subroutine
subroutine S8B(X, Z, Y)
integer, optional :: X
integer :: Z
real :: Y
end subroutine
end interface
end