PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / pointer_init_7.f90
blobdfde6156e66b4fd4ed0aa742ea4aac479bc025ac
1 ! { dg-do compile }
3 ! PR fortran/55763
6 subroutine sub()
7 type t
8 integer :: i
9 end type t
11 type(t), target :: tgt
12 type(t), target, save :: tgt2(2)
14 type t2a
15 type(t), pointer :: cmp1 => tgt ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
16 end type t2a
18 type t2b
19 class(t), pointer :: cmp2 => tgt ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
20 end type t2b
22 type t2c
23 class(t), pointer :: cmp3 => tgt ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
24 end type t2c
26 type t2d
27 integer, pointer :: cmp4 => tgt%i ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
28 end type t2d
30 type(t), pointer :: w => tgt ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
31 class(t), pointer :: x => tgt ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
32 class(*), pointer :: y => tgt ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
33 integer, pointer :: z => tgt%i ! { dg-error "Pointer initialization target at .1. must have the SAVE attribute" }
34 end subroutine
36 program main
37 type t3
38 integer :: j
39 end type t3
41 type(t3), target :: tgt
43 type t4
44 type(t3), pointer :: cmp1 => tgt ! OK
45 class(t3), pointer :: cmp2 => tgt ! OK
46 class(t3), pointer :: cmp3 => tgt ! OK
47 integer, pointer :: cmp4 => tgt%j ! OK
48 end type t4
50 type(t3), target :: mytarget
52 type(t3), pointer :: a => mytarget ! OK
53 class(t3), pointer :: b => mytarget ! OK
54 class(*), pointer :: c => mytarget ! OK
55 integer, pointer :: d => mytarget%j ! OK
56 end program main