[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / null-init.f90
blobd5ed4d12f8094c5cb36d46beaf855faf9c2da40f
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1
2 ! REQUIRES: shell
3 ! Tests valid and invalid NULL initializers
5 module m1
6 implicit none
7 !ERROR: No explicit type declared for 'null'
8 private :: null
9 end module
11 module m2
12 implicit none
13 private :: null
14 integer, pointer :: p => null()
15 end module
17 module m3
18 private :: null
19 integer, pointer :: p => null()
20 end module
22 module m4
23 intrinsic :: null
24 integer, pointer :: p => null()
25 end module
27 module m5
28 external :: null
29 !ERROR: Pointer initializer must be intrinsic NULL()
30 integer, pointer :: p => null()
31 end module
33 module m6
34 !ERROR: Symbol 'null' cannot have both INTRINSIC and EXTERNAL attributes
35 integer, pointer :: p => null()
36 external :: null
37 end module
39 module m7
40 interface
41 function null() result(p)
42 integer, pointer :: p
43 end function
44 end interface
45 !ERROR: Pointer initializer must be intrinsic NULL()
46 integer, pointer :: p => null()
47 end module
49 module m8
50 integer, pointer :: p => null()
51 interface
52 !ERROR: 'null' is already declared in this scoping unit
53 function null() result(p)
54 integer, pointer :: p
55 end function
56 end interface
57 end module
59 module m9a
60 intrinsic :: null
61 contains
62 function foo()
63 integer, pointer :: foo
64 foo => null()
65 end function
66 end module
67 module m9b
68 use m9a, renamed => null, null => foo
69 integer, pointer :: p => renamed()
70 !ERROR: Pointer initializer must be intrinsic NULL()
71 integer, pointer :: q => null()
72 integer, pointer :: d1, d2
73 data d1/renamed()/
74 !ERROR: An initial data target must be a designator with constant subscripts
75 data d2/null()/
76 end module