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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [recursive_reference_1.f90] - Blame information for rev 694

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 694 jeremybenn
! { dg-do compile }
2
! Tests the patch for PR27613, in which directly recursive, scalar
3
! functions were generating an "unclassifiable statement" error
4
! for the recursive statement(s).  This was subsequently determined
5
! to be wrong code and the error on 'bad_stuff' was removed.
6
! See 12.5.2.1 of the standard and PR30876.
7
!
8
! Based on PR testcase by Nicolas Bock  
9
!
10
program test
11
  if (original_stuff(1) .ne. 5) call abort ()
12
  if (scalar_stuff(-4) .ne. 10) call abort ()
13
  if (any (array_stuff((/-19,-30/)) .ne. (/25,25/))) call abort ()
14
contains
15
  recursive function original_stuff(n)
16
    integer :: original_stuff
17
    integer :: n
18
    original_stuff = 1
19
    if(n < 5) then
20
      original_stuff = original_stuff + original_stuff (n+1) ! { dg-error "name of a recursive function" }
21
    endif
22
  end function original_stuff
23
 
24
  recursive function scalar_stuff(n) result (tmp)
25
    integer :: tmp
26
    integer :: n
27
    tmp = 1
28
    if(n < 5) then
29
      tmp = tmp + scalar_stuff (n+1)
30
    endif
31
  end function scalar_stuff
32
 
33
  recursive function array_stuff(n) result (tmp)
34
    integer :: tmp (2)
35
    integer :: n (2)
36
    tmp = 1
37
    if(maxval (n) < 5) then
38
      tmp = tmp + array_stuff (n+1)
39
    endif
40
  end function array_stuff
41
 
42
  recursive function bad_stuff(n)
43
    integer :: bad_stuff (2)
44
    integer :: n(2)
45
    bad_stuff = 1
46
    if(maxval (n) < 5) then
47
      bad_stuff = bad_stuff + bad_stuff (n+1)
48
    endif
49
  end function bad_stuff
50
end program test

powered by: WebSVN 2.1.0

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