80 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Check for semantic errors in move_alloc() subroutine calls3program main4 integer, allocatable :: a(:)[:], b(:)[:], f(:), g(:), h(:)[:,:]5 type alloc_component6 integer, allocatable :: a(:)7 end type8 type(alloc_component) :: c[*], d[*]9 !ERROR: 'e' is an ALLOCATABLE coarray and must have a deferred coshape10 integer, allocatable :: e(:)[*]11 integer status, coindexed_status[*]12 character(len=1) message, coindexed_message[*]13 integer :: nonAllocatable(10)14 type t15 end type16 class(t), allocatable :: t117 type(t), allocatable :: t218 character, allocatable :: ca*2, cb*319 20 ! standards conforming21 allocate(a(3)[*])22 a = [ 1, 2, 3 ]23 call move_alloc(a, b, status, message)24 25 !ERROR: too many actual arguments for intrinsic 'move_alloc'26 call move_alloc(a, b, status, message, 1)27 28 ! standards non-conforming29 !ERROR: 'from' argument to 'move_alloc' may not be a coindexed object30 call move_alloc(c[1]%a, f)31 32 !ERROR: 'to' argument to 'move_alloc' may not be a coindexed object33 call move_alloc(f, d[1]%a)34 35 !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object36 call move_alloc(f, g, coindexed_status[1])37 38 !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object39 call move_alloc(f, g, status, coindexed_message[1])40 41 !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object42 call move_alloc(f, g, errmsg=coindexed_message[1])43 44 !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object45 call move_alloc(f, g, errmsg=coindexed_message[1], stat=status)46 47 !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object48 call move_alloc(f, g, stat=coindexed_status[1])49 50 !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object51 call move_alloc(f, g, errmsg=message, stat=coindexed_status[1])52 53 !ERROR: 'from' argument to 'move_alloc' may not be a coindexed object54 !ERROR: 'to' argument to 'move_alloc' may not be a coindexed object55 !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object56 !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object57 call move_alloc(c[1]%a, d[1]%a, stat=coindexed_status[1], errmsg=coindexed_message[1])58 59 !ERROR: Argument #1 to MOVE_ALLOC must be allocatable60 call move_alloc(nonAllocatable, f)61 !ERROR: Argument #2 to MOVE_ALLOC must be allocatable62 call move_alloc(f, nonAllocatable)63 64 !ERROR: When MOVE_ALLOC(FROM=) is polymorphic, TO= must also be polymorphic65 call move_alloc(t1, t2)66 call move_alloc(t2, t1) ! ok67 68 !ERROR: Actual argument for 'to=' has bad type or kind 'CHARACTER(KIND=1,LEN=3_8)'69 call move_alloc(ca, cb)70 71 !ERROR: Argument #1 to MOVE_ALLOC must be allocatable72 call move_alloc(f(::2), g)73 !ERROR: Argument #2 to MOVE_ALLOC must be allocatable74 call move_alloc(f, g(::2))75 76 !ERROR: FROM= argument to MOVE_ALLOC has corank 1, but TO= argument has corank 277 call move_alloc(a, h)78 79end program main80