37 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2! Check errors in TRANSFER()3 4subroutine subr(o)5 integer, intent(in), optional :: o6 type empty7 end type8 type(empty) :: empty1(1)9 type hasdescriptor10 real, allocatable :: allocatable11 end type12 type(hasdescriptor) hasDesc13 real :: empty2(0)14 character(0) :: empty3(1)15 integer, pointer :: source(:)16 integer, allocatable :: ia17 integer, pointer :: ip18 !ERROR: Element size of MOLD= array may not be zero when SOURCE= is not empty19 print *, transfer(1., empty1)20 print *, transfer(1., empty2) ! ok21 !ERROR: Element size of MOLD= array may not be zero when SOURCE= is not empty22 print *, transfer(1., empty3)23 !WARNING: Element size of MOLD= array may not be zero unless SOURCE= is empty [-Wvoid-mold]24 print *, transfer(source, empty1)25 print *, transfer(source, empty2) ! ok26 !WARNING: Element size of MOLD= array may not be zero unless SOURCE= is empty [-Wvoid-mold]27 print *, transfer(source, empty3)28 !ERROR: SIZE= argument may not be the optional dummy argument 'o'29 print *, transfer(1., empty2, size=o)30 !WARNING: SIZE= argument that is allocatable or pointer must be present at execution; parenthesize to silence this warning [-Wtransfer-size-presence]31 print *, transfer(1., empty2, size=ia)32 !WARNING: SIZE= argument that is allocatable or pointer must be present at execution; parenthesize to silence this warning [-Wtransfer-size-presence]33 print *, transfer(1., empty2, size=ip)34 !WARNING: Source of TRANSFER contains allocatable or pointer component %allocatable [-Wpointer-component-transfer-arg]35 print *, transfer(hasDesc, 1)36end37