48 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2! Tests of selectors whose defining expressions are pointer-valued functions;3! they must be valid targets, but not pointers.4! (F'2018 11.1.3.3 p1) "The associating entity does not have the ALLOCATABLE or5! POINTER attributes; it has the TARGET attribute if and only if the selector6! is a variable and has either the TARGET or POINTER attribute."7module m18 type t9 contains10 procedure, nopass :: iptr11 end type12 contains13 function iptr(n)14 integer, intent(in), target :: n15 integer, pointer :: iptr16 !WARNING: Pointer target is not a definable variable [-Wpointer-to-undefinable]17 !BECAUSE: 'n' is an INTENT(IN) dummy argument18 iptr => n19 end function20 subroutine test21 type(t) tv22 integer, target :: itarget23 integer, pointer :: ip24 associate (sel => iptr(itarget))25 ip => sel26 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer27 if (.not. associated(sel)) stop28 end associate29 associate (sel => tv%iptr(itarget))30 ip => sel31 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer32 if (.not. associated(sel)) stop33 end associate34 associate (sel => (iptr(itarget)))35 !ERROR: In assignment to object pointer 'ip', the target 'sel' is not an object with POINTER or TARGET attributes36 ip => sel37 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer38 if (.not. associated(sel)) stop39 end associate40 associate (sel => 0 + iptr(itarget))41 !ERROR: In assignment to object pointer 'ip', the target 'sel' is not an object with POINTER or TARGET attributes42 ip => sel43 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer44 if (.not. associated(sel)) stop45 end associate46 end subroutine47end module48