[flang] call06.f90

Original-commit: flang-compiler/f18@81b64dacaa
Reviewed-on: https://github.com/flang-compiler/f18/pull/711
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-09-04 15:08:53 -07:00
parent 0e1259db7a
commit 7ffe10c1fb
2 changed files with 186 additions and 0 deletions

View File

@ -0,0 +1,117 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
! Test 15.5.2.5 constraints and restrictions for POINTER & ALLOCATABLE
! arguments when both sides of the call have the same attributes.
module m
type :: t
end type
type, extends(t) :: t2
end type
type :: pdt(n)
integer, len :: n
end type
type(t), pointer :: mp(:), mpmat(:,:)
type(t), allocatable :: ma(:), mamat(:,:)
class(t), pointer :: pp(:)
class(t), allocatable :: pa(:)
class(t2), pointer :: pp2(:)
class(t2), allocatable :: pa2(:)
class(*), pointer :: up(:)
class(*), allocatable :: ua(:)
type(pdt(*)), pointer :: dmp(:)
type(pdt(*)), allocatable :: dma(:)
type(pdt(1)), pointer :: nmp(:)
type(pdt(1)), allocatable :: nma(:)
contains
subroutine smp(x)
type(t), pointer :: x(:)
end subroutine
subroutine sma(x)
type(t), allocatable :: x(:)
end subroutine
subroutine spp(x)
class(t), pointer :: x(:)
end subroutine
subroutine spa(x)
class(t), allocatable :: x(:)
end subroutine
subroutine sup(x)
class(*), pointer :: x(:)
end subroutine
subroutine sua(x)
class(*), allocatable :: x(:)
end subroutine
subroutine sdmp(x)
type(pdt(*)), pointer :: x(:)
end subroutine
subroutine sdma(x)
type(pdt(*)), pointer :: x(:)
end subroutine
subroutine snmp(x)
type(pdt(1)), pointer :: x(:)
end subroutine
subroutine snma(x)
type(pdt(1)), pointer :: x(:)
end subroutine
subroutine test
call smp(mp) ! ok
call sma(ma) ! ok
call spp(pp) ! ok
call spa(pa) ! ok
! ERROR: If a dummy or effective argument is polymorphic, both must be so.
call smp(pp)
! ERROR: If a dummy or effective argument is polymorphic, both must be so.
call sma(pp)
! ERROR: If a dummy or effective argument is polymorphic, both must be so.
call spp(mp)
! ERROR: If a dummy or effective argument is polymorphic, both must be so.
call spa(mp)
! ERROR: If a dummy or effective argument is unlimited polymorphic, both must be so.
call sup(pp)
! ERROR: If a dummy or effective argument is unlimited polymorphic, both must be so.
call sua(pa)
! ERROR: If a dummy or effective argument is unlimited polymorphic, both must be so.
call spp(up)
! ERROR: If a dummy or effective argument is unlimited polymorphic, both must be so.
call spa(ua)
! ERROR: Dummy and effective arguments must have the same declared type.
call spp(pp2)
! ERROR: Dummy and effective arguments must have the same declared type.
call spa(pa2)
! ERROR: Dummy argument has rank 1, but effective argument has rank 2.
call smp(mpmat)
! ERROR: Dummy argument has rank 1, but effective argument has rank 2.
call sma(mamat)
call sdmp(dmp) ! ok
call sdma(dma) ! ok
call snmp(nmp) ! ok
call snma(nma) ! ok
! ERROR: Dummy and effective arguments must defer the same type parameters.
call sdmp(nmp)
! ERROR: Dummy and effective arguments must defer the same type parameters.
call sdma(nma)
! ERROR: Dummy and effective arguments must defer the same type parameters.
call snmp(dmp)
! ERROR: Dummy and effective arguments must defer the same type parameters.
call snma(dma)
end subroutine
end module

View File

@ -0,0 +1,69 @@
! Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
! Test 15.5.2.6 constraints and restrictions for ALLOCATABLE
! dummy arguments.
module m
real, allocatable :: cov[:], com[:,:]
contains
subroutine s01(x)
real, allocatable :: x
end subroutine
subroutine s02(x)
real, allocatable :: x[:]
end subroutine
subroutine s03(x)
real, allocatable :: x[:,:]
end subroutine
subroutine s04(x)
real, allocatable, intent(in) :: x
end subroutine
subroutine s05(x)
real, allocatable, intent(out) :: x
end subroutine
subroutine s06(x)
real, allocatable, intent(in out) :: x
end subroutine
function allofunc()
real, allocatable :: allofunc
end function
subroutine test(x)
real :: scalar
real, allocatable, intent(in) :: x
! ERROR: ALLOCATABLE dummy argument must be associated with an ALLOCATABLE effective argument
call s01(scalar)
! ERROR: ALLOCATABLE dummy argument must be associated with an ALLOCATABLE effective argument
call s01(1.)
! ERROR: ALLOCATABLE dummy argument must be associated with an ALLOCATABLE effective argument
call s01(allofunc()) ! subtle: ALLOCATABLE function result isn't
call s02(cov) ! ok
call s03(com) ! ok
! ERROR: Dummy argument has corank 1, but effective argument has corank 2
call s02(com)
! ERROR: Dummy argument has corank 2, but effective argument has corank 1
call s03(cov)
call s04(cov[1]) ! ok
! ERROR: Coindexed ALLOCATABLE effective argument must be associated with INTENT(IN) dummy argument
call s01(cov[1])
! ERROR: Effective argument associated with INTENT(OUT) dummy is not definable.
call s05(x)
! ERROR: Effective argument associated with INTENT(IN OUT) dummy is not definable.
call s06(x)
end subroutine
end module