| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/93814 - ICE in build_entry_thunks with CHARACTER ENTRY |
| 4 |
! and bind(c). |
| 5 |
! |
| 6 |
! Verify that CHARACTER function results with ENTRY and bind(c) compile |
| 7 |
! and execute correctly, covering all combinations of bind(c) on the |
| 8 |
! function and its entries. |
| 9 |
|
| 10 |
! Both function and entry have bind(c). |
| 11 |
function f1() bind(c) |
| 12 |
character :: f1, g1 |
| 13 |
f1 = "a" |
| 14 |
return |
| 15 |
entry g1() bind(c) |
| 16 |
g1 = "b" |
| 17 |
end |
| 18 |
|
| 19 |
! Only function has bind(c), entry does not. |
| 20 |
function f2() bind(c) |
| 21 |
character(1) :: f2, g2 |
| 22 |
f2 = "c" |
| 23 |
return |
| 24 |
entry g2() |
| 25 |
g2 = "d" |
| 26 |
end function |
| 27 |
|
| 28 |
! Only entry has bind(c), function does not. |
| 29 |
function f3() |
| 30 |
character(1) :: f3, g3 |
| 31 |
f3 = "e" |
| 32 |
return |
| 33 |
entry g3() bind(c) |
| 34 |
g3 = "f" |
| 35 |
end function |
| 36 |
|
| 37 |
! Neither function nor entry have bind(c) (baseline). |
| 38 |
function f4() |
| 39 |
character :: f4, g4 |
| 40 |
f4 = "g" |
| 41 |
return |
| 42 |
entry g4() |
| 43 |
g4 = "h" |
| 44 |
end |
| 45 |
|
| 46 |
! Integer with bind(c) (should still work). |
| 47 |
function f5() bind(c) |
| 48 |
integer :: f5, g5 |
| 49 |
f5 = 42 |
| 50 |
return |
| 51 |
entry g5() bind(c) |
| 52 |
g5 = 84 |
| 53 |
end |
| 54 |
|
| 55 |
program p |
| 56 |
interface |
| 57 |
function f1() bind(c) |
| 58 |
character :: f1 |
| 59 |
end |
| 60 |
function g1() bind(c) |
| 61 |
character :: g1 |
| 62 |
end |
| 63 |
function f2() bind(c) |
| 64 |
character(1) :: f2 |
| 65 |
end |
| 66 |
function g2() |
| 67 |
character(1) :: g2 |
| 68 |
end |
| 69 |
function f3() |
| 70 |
character(1) :: f3 |
| 71 |
end |
| 72 |
function g3() bind(c) |
| 73 |
character(1) :: g3 |
| 74 |
end |
| 75 |
function f4() |
| 76 |
character :: f4 |
| 77 |
end |
| 78 |
function g4() |
| 79 |
character :: g4 |
| 80 |
end |
| 81 |
function f5() bind(c) |
| 82 |
integer :: f5 |
| 83 |
end |
| 84 |
function g5() bind(c) |
| 85 |
integer :: g5 |
| 86 |
end |
| 87 |
end interface |
| 88 |
|
| 89 |
if (f1() /= "a") stop 1 |
| 90 |
if (g1() /= "b") stop 2 |
| 91 |
if (f2() /= "c") stop 3 |
| 92 |
if (g2() /= "d") stop 4 |
| 93 |
if (f3() /= "e") stop 5 |
| 94 |
if (g3() /= "f") stop 6 |
| 95 |
if (f4() /= "g") stop 7 |
| 96 |
if (g4() /= "h") stop 8 |
| 97 |
if (f5() /= 42) stop 9 |
| 98 |
if (g5() /= 84) stop 10 |
| 99 |
end |