| 1 |
! { dg-do run } |
| 2 |
! { dg-options -Wsurprising } |
| 3 |
integer, pointer :: p |
| 4 |
integer, target :: t, s |
| 5 |
|
| 6 |
! The tests for character pointers are currently commented out, |
| 7 |
! because they don't yet work correctly. |
| 8 |
! This is PR 17192 |
| 9 |
!!$character*5, pointer :: d |
| 10 |
!!$character*5, target :: c, e |
| 11 |
|
| 12 |
t = 1 |
| 13 |
p => s |
| 14 |
! We didn't dereference the pointer in the following line. |
| 15 |
p = f() ! { dg-warning "POINTER-valued function" } |
| 16 |
p = p+1 |
| 17 |
if (p.ne.2) STOP 1 |
| 18 |
if (p.ne.s) STOP 2 |
| 19 |
|
| 20 |
!!$! verify that we also dereference correctly the result of a function |
| 21 |
!!$! which returns its result by reference |
| 22 |
!!$c = "Hallo" |
| 23 |
!!$d => e |
| 24 |
!!$d = g() ! dg-warning "POINTER valued function" "" |
| 25 |
!!$if (d.ne."Hallo") STOP 3 |
| 26 |
|
| 27 |
contains |
| 28 |
function f() |
| 29 |
integer, pointer :: f |
| 30 |
f => t |
| 31 |
end function f |
| 32 |
!!$function g() |
| 33 |
!!$character, pointer :: g |
| 34 |
!!$g => c |
| 35 |
!!$end function g |
| 36 |
end |