2 ! { dg-options "-fwhole-file -fdump-tree-original" }
4 ! PR fortran/43042 - fix ICE with c_null_ptr when using
5 ! -fwhole-file (or -flto, which implies -fwhole-file).
7 ! Testcase based on c_ptr_tests_14.f90 (PR fortran/41298)
8 ! Check that c_null_ptr default initializer is really applied
12 type, public :: fgsl_file
13 type(c_ptr) :: gsl_file = c_null_ptr
14 type(c_funptr) :: gsl_func = c_null_funptr
16 type(c_funptr) :: NIfunptr
19 subroutine sub(aaa,bbb)
20 type(fgsl_file), intent(out) :: aaa
21 type(fgsl_file), intent(inout) :: bbb
23 subroutine proc() bind(C)
30 type(fgsl_file) :: file, noreinit
31 integer, target :: tgt
33 call sub(file, noreinit)
34 if(c_associated(file%gsl_file)) call abort()
35 if(c_associated(file%gsl_func)) call abort()
37 file%gsl_file = c_loc(tgt)
38 file%gsl_func = c_funloc(proc)
39 call sub(file, noreinit)
40 if(c_associated(file%gsl_file)) call abort()
41 if(c_associated(file%gsl_func)) call abort()
44 ! { dg-final { scan-tree-dump-times "gsl_file = 0B" 1 "original" } }
45 ! { dg-final { scan-tree-dump-times "gsl_func = 0B" 1 "original" } }
47 ! { dg-final { scan-tree-dump-times "NIptr = 0B" 0 "original" } }
48 ! { dg-final { scan-tree-dump-times "NIfunptr = 0B" 0 "original" } }
50 ! { dg-final { scan-tree-dump-times "bbb =" 0 "original" } }
52 ! { dg-final { cleanup-tree-dump "original" } }
53 ! { dg-final { cleanup-modules "m" } }