104 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Tests valid and invalid NULL initializers3 4module m15 implicit none6 !ERROR: No explicit type declared for 'null'7 private :: null8end module9 10module m211 implicit none12 private :: null13 integer, pointer :: p => null()14end module15 16module m317 private :: null18 integer, pointer :: p => null()19end module20 21module m422 intrinsic :: null23 integer, pointer :: p => null()24end module25 26module m527 external :: null28 !ERROR: Pointer initializer must be intrinsic NULL()29 integer, pointer :: p => null()30end module31 32module m633 !ERROR: Symbol 'null' cannot have both INTRINSIC and EXTERNAL attributes34 integer, pointer :: p => null()35 external :: null36end module37 38module m739 interface40 !WARNING: The external interface 'null' is not compatible with an earlier definition (function results have incompatible attributes) [-Wexternal-interface-mismatch]41 function null() result(p)42 integer, pointer :: p43 end function44 end interface45 !ERROR: Pointer initializer must be intrinsic NULL()46 integer, pointer :: p => null()47end module48 49module m850 integer, pointer :: p => null()51 interface52 !ERROR: 'null' is already declared in this scoping unit53 function null() result(p)54 integer, pointer :: p55 end function56 end interface57end module58 59module m9a60 intrinsic :: null61 contains62 function foo()63 integer, pointer :: foo64 foo => null()65 end function66end module67module m9b68 use m9a, renamed => null, null => foo69 integer, pointer :: p => renamed()70 !ERROR: Pointer initializer must be intrinsic NULL()71 integer, pointer :: q => null()72 integer, pointer :: d1, d273 data d1/renamed()/74 !ERROR: An initial data target must be a designator with constant subscripts75 data d2/null()/76end module77 78subroutine m1079 real, pointer :: x, y80 !ERROR: 'null' must be an array or structure constructor if used with non-empty parentheses as a DATA statement constant81 data x/null(y)/82end83 84subroutine m1185 type :: null86 integer :: mold87 end type88 type(null) :: obj(2)89 integer, parameter :: j = 090 data obj/null(mold=j), null(j)/ ! both fine91end subroutine92 93subroutine m1294 integer, parameter :: j = 195 integer, target, save :: null(1)96 integer, pointer :: p97 data p/null(j)/ ! ok98end subroutine99 100subroutine s13101 integer, external, pointer :: p1 => null()102 procedure(), pointer :: p2 => null()103end subroutine104