1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
! Tests ELEMENTAL subprogram constraints C15100-15102
!ERROR: An ELEMENTAL subroutine may not have an alternate return dummy argument
elemental subroutine altret(*)
end subroutine
elemental subroutine arrarg(a)
!ERROR: A dummy argument of an ELEMENTAL procedure must be scalar
real, intent(in) :: a(1)
end subroutine
elemental subroutine alloarg(a)
!ERROR: A dummy argument of an ELEMENTAL procedure may not be ALLOCATABLE
real, intent(in), allocatable :: a
end subroutine
elemental subroutine coarg(a)
!ERROR: A dummy argument of an ELEMENTAL procedure may not be a coarray
real, intent(in) :: a[*]
end subroutine
elemental subroutine ptrarg(a)
!ERROR: A dummy argument of an ELEMENTAL procedure may not be a POINTER
real, intent(in), pointer :: a
end subroutine
impure elemental subroutine barearg(a)
!ERROR: A dummy argument of an ELEMENTAL procedure must have an INTENT() or VALUE attribute
real :: a
end subroutine
elemental function arrf(n)
integer, value :: n
!ERROR: The result of an ELEMENTAL function must be scalar
real :: arrf(n)
end function
elemental function allof(n)
integer, value :: n
!ERROR: The result of an ELEMENTAL function may not be ALLOCATABLE
real, allocatable :: allof
end function
elemental function ptrf(n)
integer, value :: n
!ERROR: The result of an ELEMENTAL function may not be a POINTER
real, pointer :: ptrf
end function
module m
integer modvar
type t
character(:), allocatable :: c
end type
type pdt(L)
integer, len :: L
end type
type container
class(pdt(:)), allocatable :: c
end type
contains
!ERROR: Invalid specification expression for elemental function result: dependence on value of dummy argument 'n'
elemental character(n) function bad1(n)
integer, intent(in) :: n
end
!ERROR: Invalid specification expression for elemental function result: non-constant inquiry function 'len' not allowed for local object
elemental character(x%c%len) function bad2(x)
type(t), intent(in) :: x
end
!ERROR: Invalid specification expression for elemental function result: non-constant type parameter inquiry not allowed for local object
elemental character(x%c%L) function bad3(x)
class(container), intent(in) :: x
end
elemental character(len(x)) function ok1(x) ! ok
character(*), intent(in) :: x
end
elemental character(modvar) function ok2(x) ! ok
character(*), intent(in) :: x
end
elemental character(len(x)) function ok3(x) ! ok
character(modvar), intent(in) :: x
end
elemental character(storage_size(x)) function ok4(x) ! ok
class(*), intent(in) :: x
end
end
|