Debian Codegraph @

gcc/testsuite/gfortran.dg/pr120049_2.f90

raw
1 ! Compiled with pr120049_b.f90
2 ! { dg-options -O0 }
3 ! { dg-do compile }
4 ! { dg-compile-aux-modules "pr120049_b.f90" }
5 !
6 ! Test the fix for PR120049
7 program tests_gtk_sup
8 use gtk_sup
9 implicit none
10
11 type mytype
12 integer :: myint
13 end type mytype
14 type(mytype) :: ijkl = mytype(42)
15 logical :: truth
16 real :: var1
17 type(c_ptr), target :: val
18 type(c_funptr), target :: fptr
19 character(15) :: stringy
20 complex :: certainly
21 truth = .true.
22 var1 = 86.
23 stringy = "what the hay!"
24 certainly = (3.14,-4.13)
25 if (c_associated(val, c_loc(val))) then
26 stop 1
27 endif
28 if (c_associated(c_loc(val), val)) then
29 stop 2
30 endif
31 print *, c_associated(fptr, C_NULL_FUNPTR)
32 print *, c_associated(c_loc(val), C_NULL_PTR)
33 print *, c_associated(C_NULL_PTR, c_loc(val))
34 print *, c_associated(c_loc(val), 42) ! { dg-error "C_ASSOCIATED shall have the" }
35 print *, c_associated(c_loc(val), .42) ! { dg-error "C_ASSOCIATED shall have the" }
36 print *, c_associated(c_loc(val), truth) ! { dg-error "C_ASSOCIATED shall have the" }
37 print *, c_associated(c_loc(val), .false.) ! { dg-error "C_ASSOCIATED shall have the" }
38 print *, c_associated(c_loc(val), var1) ! { dg-error "C_ASSOCIATED shall have the" }
39 print *, c_associated(c_loc(val), stringy) ! { dg-error "C_ASSOCIATED shall have the" }
40 print *, c_associated(c_loc(val), certainly) ! { dg-error "C_ASSOCIATED shall have the" }
41 print *, c_associated(42) ! { dg-error "C_ASSOCIATED shall have the" }
42 print *, c_associated(.42) ! { dg-error "C_ASSOCIATED shall have the" }
43 print *, c_associated(truth) ! { dg-error "C_ASSOCIATED shall have the" }
44 print *, c_associated(.false.) ! { dg-error "C_ASSOCIATED shall have the" }
45 print *, c_associated(var1) ! { dg-error "C_ASSOCIATED shall have the" }
46 print *, c_associated(stringy) ! { dg-error "C_ASSOCIATED shall have the" }
47 print *, c_associated(certainly) ! { dg-error "C_ASSOCIATED shall have the" }
48 print *, c_associated(.42) ! { dg-error "C_ASSOCIATED shall have the" }
49 print *, c_associated(val, testit(val)) ! { dg-error "C_ASSOCIATED shall have the" }
50 print *, c_associated(testit(val), val) ! { dg-error "C_ASSOCIATED shall have the" }
51 print *, c_associated(testit(val)) ! { dg-error "C_ASSOCIATED shall have the" }
52 print *, c_associated(c_loc(val), C_NULL_FUNPTR) ! { dg-error "C_ASSOCIATED shall have the" }
53 print *, c_associated(C_NULL_FUNPTR, c_loc(val)) ! { dg-error "C_ASSOCIATED shall have the" }
54 contains
55
56 function testit (avalue) result(res)
57 type(c_ptr) :: avalue
58 type(mytype) :: res
59 res%myint = 42
60 end function
61
62 end program tests_gtk_sup