xref: /llvm-project/flang/test/Semantics/nullify02.f90 (revision 573fc6187b82290665ed7d94aa50641d06260a9e)
16c1ac141SIvan Zhechev! RUN: %python %S/test_errors.py %s %flang_fc1
264ab3302SCarolineConcatto! Check for semantic errors in NULLIFY statements
364ab3302SCarolineConcatto
464ab3302SCarolineConcattoINTEGER, PARAMETER :: maxvalue=1024
564ab3302SCarolineConcatto
664ab3302SCarolineConcattoType dt
764ab3302SCarolineConcatto  Integer :: l = 3
864ab3302SCarolineConcattoEnd Type
964ab3302SCarolineConcattoType t
1064ab3302SCarolineConcatto  Type(dt) :: p
1164ab3302SCarolineConcattoEnd Type
1264ab3302SCarolineConcatto
1364ab3302SCarolineConcattoType(t),Allocatable :: x(:)
1464ab3302SCarolineConcatto
1564ab3302SCarolineConcattoInteger :: pi
1664ab3302SCarolineConcattoProcedure(Real) :: prp
1764ab3302SCarolineConcatto
1864ab3302SCarolineConcattoAllocate(x(3))
19*573fc618SPeter Klausler!ERROR: 'p' may not appear in NULLIFY
20*573fc618SPeter Klausler!BECAUSE: 'p' is not a pointer
2164ab3302SCarolineConcattoNullify(x(2)%p)
2264ab3302SCarolineConcatto
23*573fc618SPeter Klausler!ERROR: 'pi' may not appear in NULLIFY
24*573fc618SPeter Klausler!BECAUSE: 'pi' is not a pointer
2564ab3302SCarolineConcattoNullify(pi)
2664ab3302SCarolineConcatto
27*573fc618SPeter Klausler!ERROR: 'prp' may not appear in NULLIFY
28*573fc618SPeter Klausler!BECAUSE: 'prp' is not a pointer
2964ab3302SCarolineConcattoNullify(prp)
3064ab3302SCarolineConcatto
31*573fc618SPeter Klausler!ERROR: 'maxvalue' may not appear in NULLIFY
32*573fc618SPeter Klausler!BECAUSE: 'maxvalue' is not a pointer
3364ab3302SCarolineConcattoNullify(maxvalue)
3464ab3302SCarolineConcatto
3564ab3302SCarolineConcattoEnd Program
36cfd7d812SPeter Steinfeld
37cfd7d812SPeter Steinfeld! Make sure that the compiler doesn't crash when NULLIFY is used in a context
38cfd7d812SPeter Steinfeld! that has reported errors
39cfd7d812SPeter Steinfeldmodule badNullify
40cfd7d812SPeter Steinfeld  interface
4139686557SPeter Klausler    function ptrFun()
42cfd7d812SPeter Steinfeld      integer, pointer :: ptrFun
43cfd7d812SPeter Steinfeld    end function
44cfd7d812SPeter Steinfeld  end interface
45cfd7d812SPeter Steinfeldcontains
46cfd7d812SPeter Steinfeld  !ERROR: 'ptrfun' was not declared a separate module procedure
47bfc39073SPeter Klausler  !ERROR: 'ptrfun' is already declared in this scoping unit
48cfd7d812SPeter Steinfeld  module function ptrFun()
49cfd7d812SPeter Steinfeld    integer, pointer :: ptrFun
50cfd7d812SPeter Steinfeld    real :: realVar
51cfd7d812SPeter Steinfeld    nullify(ptrFun)
52*573fc618SPeter Klausler    !ERROR: 'realvar' may not appear in NULLIFY
53*573fc618SPeter Klausler    !BECAUSE: 'realvar' is not a pointer
54cfd7d812SPeter Steinfeld    nullify(realVar)
55cfd7d812SPeter Steinfeld  end function
56cfd7d812SPeter Steinfeldend module
57