OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gfortran.dg/] [ret_pointer_2.f90] - Blame information for rev 841

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
! { dg-do run }
2
! PR 25806: Functions returning pointers to arrays
3
program a
4
    integer, target :: storage(5)
5
    integer :: s(3)
6
 
7
 
8
    print *, x(3)  ! { dg-output " *1  *2  *3" }
9
 
10
    if (ssum(x(3)) /= 6) call abort()
11
 
12
    s = 0
13
    s = x(3)
14
    if (any(s /= (/1, 2, 3/))) call abort()
15
 
16
contains
17
 
18
    function x(n) result(t)
19
        integer, intent(in) :: n
20
        integer, pointer :: t(:)
21
        integer :: i
22
 
23
        t => storage(1:n)
24
        t = (/ (i, i = 1, n) /)
25
 
26
    end function x
27
 
28
 
29
    integer function ssum(a)
30
        integer, intent(in) :: a(:)
31
 
32
        ssum = sum(a)
33
 
34
    end function ssum
35
 
36
end program a
37
 
38
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.