2 ! { dg-options "-fdump-tree-original" }
6 ! Check that c_null_ptr default initializer is really applied
10 type, public
:: fgsl_file
11 type(c_ptr
) :: gsl_file
= c_null_ptr
12 type(c_funptr
) :: gsl_func
= c_null_funptr
14 type(c_funptr
) :: NIfunptr
17 subroutine sub(aaa
,bbb
)
18 type(fgsl_file
), intent(out
) :: aaa
19 type(fgsl_file
), intent(inout
) :: bbb
21 subroutine proc() bind(C
)
28 type(fgsl_file
) :: file
, noreinit
29 integer, target
:: tgt
31 call sub(file
, noreinit
)
32 if(c_associated(file
%gsl_file
)) call abort()
33 if(c_associated(file
%gsl_func
)) call abort()
35 file
%gsl_file
= c_loc(tgt
)
36 file
%gsl_func
= c_funloc(proc
)
37 call sub(file
, noreinit
)
38 if(c_associated(file
%gsl_file
)) call abort()
39 if(c_associated(file
%gsl_func
)) call abort()
42 ! { dg-final { scan-tree-dump-times "c_funptr.\[0-9\]+ = 0B;" 1 "original" } }
43 ! { dg-final { scan-tree-dump-times "fgsl_file.\[0-9\]+.gsl_func = c_funptr.\[0-9\]+;" 1 "original" } }
44 ! { dg-final { scan-tree-dump-times "c_ptr.\[0-9\]+ = 0B;" 1 "original" } }
45 ! { dg-final { scan-tree-dump-times "fgsl_file.\[0-9\]+.gsl_file = c_ptr.\[0-9\]+;" 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" } }