1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2 ! 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 or
5 ! POINTER attributes; it has the TARGET attribute if and only if the selector
6 ! is a variable and has either the TARGET or POINTER attribute."
10 procedure
, nopass
:: iptr
14 integer, intent(in
), target
:: n
15 integer, pointer :: iptr
16 !WARNING: Pointer target is not a definable variable
17 !BECAUSE: 'n' is an INTENT(IN) dummy argument
22 integer, target
:: itarget
23 integer, pointer :: ip
24 associate (sel
=> iptr(itarget
))
26 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer
27 if (.not
. associated(sel
)) stop
29 associate (sel
=> tv
%iptr(itarget
))
31 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer
32 if (.not
. associated(sel
)) stop
34 associate (sel
=> (iptr(itarget
)))
35 !ERROR: In assignment to object pointer 'ip', the target 'sel' is not an object with POINTER or TARGET attributes
37 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer
38 if (.not
. associated(sel
)) stop
40 associate (sel
=> 0 + iptr(itarget
))
41 !ERROR: In assignment to object pointer 'ip', the target 'sel' is not an object with POINTER or TARGET attributes
43 !ERROR: POINTER= argument of ASSOCIATED() must be a pointer
44 if (.not
. associated(sel
)) stop