xref: /llvm-project/flang/test/Semantics/nullify02.f90 (revision 573fc6187b82290665ed7d94aa50641d06260a9e)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for semantic errors in NULLIFY statements
3
4INTEGER, PARAMETER :: maxvalue=1024
5
6Type dt
7  Integer :: l = 3
8End Type
9Type t
10  Type(dt) :: p
11End Type
12
13Type(t),Allocatable :: x(:)
14
15Integer :: pi
16Procedure(Real) :: prp
17
18Allocate(x(3))
19!ERROR: 'p' may not appear in NULLIFY
20!BECAUSE: 'p' is not a pointer
21Nullify(x(2)%p)
22
23!ERROR: 'pi' may not appear in NULLIFY
24!BECAUSE: 'pi' is not a pointer
25Nullify(pi)
26
27!ERROR: 'prp' may not appear in NULLIFY
28!BECAUSE: 'prp' is not a pointer
29Nullify(prp)
30
31!ERROR: 'maxvalue' may not appear in NULLIFY
32!BECAUSE: 'maxvalue' is not a pointer
33Nullify(maxvalue)
34
35End Program
36
37! Make sure that the compiler doesn't crash when NULLIFY is used in a context
38! that has reported errors
39module badNullify
40  interface
41    function ptrFun()
42      integer, pointer :: ptrFun
43    end function
44  end interface
45contains
46  !ERROR: 'ptrfun' was not declared a separate module procedure
47  !ERROR: 'ptrfun' is already declared in this scoping unit
48  module function ptrFun()
49    integer, pointer :: ptrFun
50    real :: realVar
51    nullify(ptrFun)
52    !ERROR: 'realvar' may not appear in NULLIFY
53    !BECAUSE: 'realvar' is not a pointer
54    nullify(realVar)
55  end function
56end module
57