llvm-project/flang/test/Semantics/move_alloc.f90
Katherine Rasmussen 2944f8ef04 [flang] Add co_sum to the list of intrinsics and update test
Add the collective subroutine, co_sum, to the list of intrinsics.
In accordance with 16.9.50 and 16.9.137, add a check for and an
error if coindexed objects are being passed to certain arguments
in co_sum and in move_alloc. Add a semantics test to check that
this error is successfully caught in calls to move_alloc. Remove
the XFAIL directive, update the ERROR directives and add
standard-conforming and non-standard conforming calls in the
semantics test for co_sum.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D114134
2022-09-08 09:38:24 -07:00

53 lines
2.0 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Check for semantic errors in move_alloc() subroutine calls
program main
integer, allocatable :: a(:)[:], b(:)[:], c(:)[:], d(:)[:]
!ERROR: 'e' is an ALLOCATABLE coarray and must have a deferred coshape
integer, allocatable :: e(:)[*]
integer status, coindexed_status[*]
character(len=1) message, coindexed_message[*]
! standards conforming
allocate(a(3)[*])
a = [ 1, 2, 3 ]
call move_alloc(a, b, status, message)
allocate(c(3)[*])
c = [ 1, 2, 3 ]
!ERROR: too many actual arguments for intrinsic 'move_alloc'
call move_alloc(a, b, status, message, 1)
! standards non-conforming
!ERROR: 'from' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c[1], d)
!ERROR: 'to' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d[1])
!ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d, coindexed_status[1])
!ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d, status, coindexed_message[1])
!ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d, errmsg=coindexed_message[1])
!ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d, errmsg=coindexed_message[1], stat=status)
!ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d, stat=coindexed_status[1])
!ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c, d, errmsg=message, stat=coindexed_status[1])
!ERROR: 'from' argument to 'move_alloc' may not be a coindexed object
!ERROR: 'to' argument to 'move_alloc' may not be a coindexed object
!ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
!ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
call move_alloc(c[1], d[1], stat=coindexed_status[1], errmsg=coindexed_message[1])
end program main