Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / nullify02.f90
blob4e98d9e15f96a631d193ec6d924ac4f9e1c60e31
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Check for semantic errors in NULLIFY statements
4 INTEGER, PARAMETER :: maxvalue=1024
6 Type dt
7 Integer :: l = 3
8 End Type
9 Type t
10 Type(dt) :: p
11 End Type
13 Type(t),Allocatable :: x(:)
15 Integer :: pi
16 Procedure(Real) :: prp
18 Allocate(x(3))
19 !ERROR: 'p' may not appear in NULLIFY
20 !BECAUSE: 'p' is not a pointer
21 Nullify(x(2)%p)
23 !ERROR: 'pi' may not appear in NULLIFY
24 !BECAUSE: 'pi' is not a pointer
25 Nullify(pi)
27 !ERROR: 'prp' may not appear in NULLIFY
28 !BECAUSE: 'prp' is not a pointer
29 Nullify(prp)
31 !ERROR: 'maxvalue' may not appear in NULLIFY
32 !BECAUSE: 'maxvalue' is not a pointer
33 Nullify(maxvalue)
35 End Program
37 ! Make sure that the compiler doesn't crash when NULLIFY is used in a context
38 ! that has reported errors
39 module badNullify
40 interface
41 function ptrFun()
42 integer, pointer :: ptrFun
43 end function
44 end interface
45 contains
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
56 end module