1! { dg-do compile } 2! 3! PR fortran/55763 4! 5 6subroutine sub() 7 type t 8 integer :: i 9 end type t 10 11 type(t), target :: tgt 12 type(t), target, save :: tgt2(2) 13 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 17 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 21 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 25 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 29 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" } 34end subroutine 35 36program main 37 type t3 38 integer :: j 39 end type t3 40 41 type(t3), target :: tgt 42 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 49 50 type(t3), target :: mytarget 51 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 56end program main 57