109 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12 3! Tests for circularly defined procedures4!ERROR: Procedure 'sub' is recursively defined. Procedures in the cycle: 'sub', 'p2'5subroutine sub(p2)6 PROCEDURE(sub) :: p27end subroutine8 9subroutine circular10 procedure(sub) :: p11 contains12 !ERROR: Procedure 'sub' is recursively defined. Procedures in the cycle: 'p', 'sub', 'p2'13 subroutine sub(p2)14 procedure(p) :: p215 end subroutine16end subroutine circular17 18!ERROR: Procedure 'foo' is recursively defined. Procedures in the cycle: 'foo', 'r'19function foo() result(r)20 !ERROR: Procedure 'r' is recursively defined. Procedures in the cycle: 'foo', 'r'21 procedure(foo), pointer :: r 22end function foo23 24subroutine iface25 !ERROR: Procedure 'p' is recursively defined. Procedures in the cycle: 'p', 'sub', 'p2'26 procedure(sub) :: p27 interface28 !ERROR: Procedure 'sub' is recursively defined. Procedures in the cycle: 'p', 'sub', 'p2'29 subroutine sub(p2)30 import p31 procedure(p) :: p232 end subroutine33 end interface34 call p(sub)35end subroutine36 37subroutine mutual38 Procedure(sub1) :: p39 contains40 !ERROR: Procedure 'sub1' is recursively defined. Procedures in the cycle: 'p', 'sub1', 'arg'41 !ERROR: Procedure 'sub1' is recursively defined. Procedures in the cycle: 'sub1', 'arg', 'sub', 'p2'42 !ERROR: Procedure 'sub1' is recursively defined. Procedures in the cycle: 'sub1', 'arg'43 Subroutine sub1(arg)44 procedure(sub1) :: arg45 End Subroutine46 47 Subroutine sub(p2)48 Procedure(sub1) :: p249 End Subroutine50End subroutine51 52subroutine mutual153 Procedure(sub1) :: p54 contains55 !ERROR: Procedure 'sub1' is recursively defined. Procedures in the cycle: 'p', 'sub1', 'arg', 'sub', 'p2'56 !ERROR: Procedure 'sub1' is recursively defined. Procedures in the cycle: 'sub1', 'arg', 'sub', 'p2'57 Subroutine sub1(arg)58 procedure(sub) :: arg59 End Subroutine60 61 !ERROR: Procedure 'sub' is recursively defined. Procedures in the cycle: 'sub1', 'arg', 'sub', 'p2'62 Subroutine sub(p2)63 Procedure(sub1) :: p264 End Subroutine65End subroutine66 67subroutine twoCycle68 !ERROR: The interface for procedure 'p1' is recursively defined69 !ERROR: The interface for procedure 'p2' is recursively defined70 procedure(p1) p271 procedure(p2) p172end subroutine73 74subroutine threeCycle75 !ERROR: The interface for procedure 'p1' is recursively defined76 !ERROR: The interface for procedure 'p2' is recursively defined77 procedure(p1) p278 !ERROR: The interface for procedure 'p3' is recursively defined79 procedure(p2) p380 procedure(p3) p181end subroutine82 83module mutualSpecExprs84contains85 pure integer function f(n)86 integer, intent(in) :: n87 real arr(g(n))88 f = size(arr)89 end function90 pure integer function g(n)91 integer, intent(in) :: n92 !ERROR: Procedure 'f' is referenced before being sufficiently defined in a context where it must be so93 real arr(f(n))94 g = size(arr)95 end function96end97 98module genericInSpec99 interface int100 procedure ifunc101 end interface102 contains103 function ifunc(x)104 integer a(int(kind(1))) ! generic is ok with most compilers105 integer(size(a)), intent(in) :: x106 ifunc = x107 end108end109