| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Test the fix for the regression caused by r15-5083. |
| 4 |
! |
| 5 |
! Contributed by Neil Carlson <[email protected]> |
| 6 |
! |
| 7 |
module foo |
| 8 |
|
| 9 |
type, public :: any_matrix |
| 10 |
private |
| 11 |
class(*), allocatable :: value(:,:) |
| 12 |
end type |
| 13 |
|
| 14 |
contains |
| 15 |
|
| 16 |
function bar(this) result(uptr) |
| 17 |
class(any_matrix), target, intent(in) :: this |
| 18 |
class(*), pointer :: uptr(:,:) |
| 19 |
uptr => this%value ! Seg. fault in trans-array.cc(gfc_get_array_span) here |
| 20 |
end function |
| 21 |
|
| 22 |
function build(this) result (res) |
| 23 |
class(*) :: this(:,:) |
| 24 |
type(any_matrix) :: res |
| 25 |
res%value = this |
| 26 |
end function |
| 27 |
|
| 28 |
function evaluate (this) result (res) |
| 29 |
class(*) :: this(:,:) |
| 30 |
character(len = 2, kind = 1), allocatable :: res(:) |
| 31 |
select type (ans => this) |
| 32 |
type is (character(*)) |
| 33 |
res = reshape (ans, [4]) |
| 34 |
type is (integer) |
| 35 |
allocate (res (8)) |
| 36 |
write (res, '(i2)') ans |
| 37 |
class default |
| 38 |
res = ['no','t ','OK','!!'] |
| 39 |
end select |
| 40 |
end |
| 41 |
|
| 42 |
end module |
| 43 |
|
| 44 |
use foo |
| 45 |
class(*), allocatable :: up (:, :) |
| 46 |
character(len = 2, kind = 1) :: chr(2,2) = reshape (['ab','cd','ef','gh'], [2,2]) |
| 47 |
integer :: i(2,2) = reshape ([1,2,3,4], [2,2]) |
| 48 |
up = bar (build (chr)) |
| 49 |
if (any (evaluate (up) /= reshape (chr, [4]))) stop 1 |
| 50 |
|
| 51 |
up = bar (build (i)) |
| 52 |
if (any (evaluate (up) /= [' 1',' 2',' 3',' 4'])) stop 2 |
| 53 |
|
| 54 |
deallocate (up) |
| 55 |
end |