1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! NULL() intrinsic function error tests
9 integer, intent(in
) :: j
11 subroutine canbenull(x
, y
)
12 integer, intent(in
), optional
:: x
13 real, intent(in
), pointer :: y
20 real, intent(inout
) :: x
25 procedure(s0
), pointer, intent(inout
) :: p
29 procedure(s1
), pointer :: f3
34 integer, pointer :: ip0
38 integer, pointer :: ip1(:)
41 procedure(s0
), pointer, nopass
:: pps0
44 procedure(s1
), pointer, nopass
:: pps1
47 real, allocatable
:: ra0
55 integer, pointer :: ip0
, ip1(:), ip2(:,:)
56 integer, allocatable
:: ia0
, ia1(:), ia2(:,:)
57 real, pointer :: rp0
, rp1(:)
58 integer, parameter :: ip0r
= rank(null(mold
=ip0
))
59 integer, parameter :: ip1r
= rank(null(mold
=ip1
))
60 integer, parameter :: ip2r
= rank(null(mold
=ip2
))
61 integer, parameter :: eight
= ip0r
+ ip1r
+ ip2r
+ 5
62 real(kind
=eight
) :: r8check
63 logical, pointer :: lp
67 !ERROR: MOLD= argument to NULL() must be a pointer or allocatable
69 !ERROR: MOLD= argument to NULL() must be a pointer or allocatable
72 dt0x
= dt0(ip0
=null())
73 dt0x
= dt0(ip0
=null(ip0
))
74 dt0x
= dt0(ip0
=null(mold
=ip0
))
75 !ERROR: function result type 'REAL(4)' is not compatible with pointer type 'INTEGER(4)'
76 dt0x
= dt0(ip0
=null(mold
=rp0
))
77 !ERROR: A NULL pointer may not be used as the value for component 'n'
78 dt0x
= dt0(null(), null())
79 !ERROR: function result type 'REAL(4)' is not compatible with pointer type 'INTEGER(4)'
80 dt1x
= dt1(ip1
=null(mold
=rp1
))
81 dt2x
= dt2(pps0
=null())
82 dt2x
= dt2(pps0
=null(mold
=dt2x
%pps0
))
83 !ERROR: Procedure pointer 'pps0' associated with result of reference to function 'null' that is an incompatible procedure pointer: distinct numbers of dummy arguments
84 dt2x
= dt2(pps0
=null(mold
=dt3x
%pps1
))
85 !ERROR: Procedure pointer 'pps1' associated with result of reference to function 'null' that is an incompatible procedure pointer: distinct numbers of dummy arguments
86 dt3x
= dt3(pps1
=null(mold
=dt2x
%pps0
))
87 dt3x
= dt3(pps1
=null(mold
=dt3x
%pps1
))
88 dt4x
= dt4(null()) ! ok
89 !PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'ra0'
91 !PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'ra0'
92 !ERROR: Rank-1 array value is not compatible with scalar component 'ra0'
94 !ERROR: A NULL procedure pointer may not be used as the value for component 'ra0'
95 dt4x
= dt4(null(dt2x
%pps0
))
96 call canbenull(null(), null()) ! fine
97 call canbenull(null(mold
=ip0
), null(mold
=rp0
)) ! fine
98 !ERROR: Null pointer argument requires an explicit interface
100 !ERROR: Null pointer argument requires an explicit interface
101 call implicit(null(mold
=ip0
))
102 !ERROR: A NULL() pointer is not allowed for 'x=' intrinsic argument
103 print *, sin(null(rp0
))
104 !ERROR: A NULL() pointer is not allowed for 'source=' intrinsic argument
105 print *, transfer(null(rp0
),ip0
)
106 !ERROR: NULL() may not be used as an expression in this context
107 select
case(null(ip0
))
109 !ERROR: NULL() may not be used as an expression in this context