diff options
author | Daniel Kraft <d@domob.eu> | 2008-11-30 21:36:10 +0100 |
---|---|---|
committer | Daniel Kraft <domob@gcc.gnu.org> | 2008-11-30 21:36:10 +0100 |
commit | 1933ba0f5dc728f554beb675093126aaef7fbb5a (patch) | |
tree | dd6e71838000e064f6aa7cc84b9cf68d917569ba /gcc/testsuite/gfortran.dg | |
parent | 72b415c58668d3bd757fb8ec3be70302c339d544 (diff) | |
download | gcc-1933ba0f5dc728f554beb675093126aaef7fbb5a.zip gcc-1933ba0f5dc728f554beb675093126aaef7fbb5a.tar.gz gcc-1933ba0f5dc728f554beb675093126aaef7fbb5a.tar.bz2 |
re PR fortran/37779 (Missing RECURSIVE not detected)
2008-11-30 Daniel Kraft <d@domob.eu>
PR fortran/37779
* gfortran.h (struct gfc_entry_list): Fixed typo in comment.
* resolve.c (is_illegal_recursion): New method.
(resolve_procedure_expression): Use new is_illegal_recursion instead of
direct check and handle function symbols correctly.
(resolve_actual_arglist): Removed useless recursion check.
(resolve_function): Use is_illegal_recursion instead of direct check.
(resolve_call): Ditto.
2008-11-30 Daniel Kraft <d@domob.eu>
PR fortran/37779
* gfortran.dg/recursive_check_1.f: Changed expected error message to
the more general new one.
* gfortran.dg/recursive_check_2.f90: Ditto.
* gfortran.dg/entry_18.f90: Ditto.
* gfortran.dg/recursive_check_4.f03: Do "the same" check also for
FUNCTIONS, as this is different in details from SUBROUTINES.
* gfortran.dg/recursive_check_6.f03: New test.
From-SVN: r142299
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rw-r--r-- | gcc/testsuite/gfortran.dg/entry_18.f90 | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/recursive_check_1.f | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/recursive_check_2.f90 | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/recursive_check_4.f03 | 10 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/recursive_check_6.f03 | 66 |
5 files changed, 82 insertions, 6 deletions
diff --git a/gcc/testsuite/gfortran.dg/entry_18.f90 b/gcc/testsuite/gfortran.dg/entry_18.f90 index e00aea7..0cfe842 100644 --- a/gcc/testsuite/gfortran.dg/entry_18.f90 +++ b/gcc/testsuite/gfortran.dg/entry_18.f90 @@ -27,7 +27,7 @@ subroutine subb( g ) end function end interface real :: x, y - call mysub( glocalb ) ! { dg-error "is recursive" } + call mysub( glocalb ) ! { dg-warning "Non-RECURSIVE" } return entry glocalb( x, y ) y = x diff --git a/gcc/testsuite/gfortran.dg/recursive_check_1.f b/gcc/testsuite/gfortran.dg/recursive_check_1.f index b264f25..7c292af 100644 --- a/gcc/testsuite/gfortran.dg/recursive_check_1.f +++ b/gcc/testsuite/gfortran.dg/recursive_check_1.f @@ -1,17 +1,17 @@ ! { dg-do compile } ! PR fortran/26551 SUBROUTINE SUB() - CALL SUB() ! { dg-error "cannot call itself, as it is not RECURSIVE" } + CALL SUB() ! { dg-error "is not RECURSIVE" } END SUBROUTINE FUNCTION FUNC() RESULT (FOO) INTEGER FOO - FOO = FUNC() ! { dg-error "cannot call itself, as it is not RECURSIVE" } + FOO = FUNC() ! { dg-error "is not RECURSIVE" } END FUNCTION SUBROUTINE SUB2() ENTRY ENT2() - CALL ENT2() ! { dg-error "is not declared as RECURSIVE" } + CALL ENT2() ! { dg-error "is not RECURSIVE" } END SUBROUTINE function func2() @@ -19,7 +19,7 @@ func2 = 42 return entry c() result (foo) - foo = b() ! { dg-error "is not declared as RECURSIVE" } + foo = b() ! { dg-error "is not RECURSIVE" } return entry b() result (bar) bar = 12 diff --git a/gcc/testsuite/gfortran.dg/recursive_check_2.f90 b/gcc/testsuite/gfortran.dg/recursive_check_2.f90 index 42273f9..15608ee 100644 --- a/gcc/testsuite/gfortran.dg/recursive_check_2.f90 +++ b/gcc/testsuite/gfortran.dg/recursive_check_2.f90 @@ -12,6 +12,6 @@ return contains function barbar () - barbar = b () ! { dg-error "is not declared as RECURSIVE" } + barbar = b () ! { dg-error "is not RECURSIVE" } end function barbar end function diff --git a/gcc/testsuite/gfortran.dg/recursive_check_4.f03 b/gcc/testsuite/gfortran.dg/recursive_check_4.f03 index 2a95554..d33e535 100644 --- a/gcc/testsuite/gfortran.dg/recursive_check_4.f03 +++ b/gcc/testsuite/gfortran.dg/recursive_check_4.f03 @@ -16,6 +16,16 @@ CONTAINS procptr => test ! { dg-warning "Non-RECURSIVE" } END SUBROUTINE test + INTEGER FUNCTION test2 () RESULT (x) + IMPLICIT NONE + PROCEDURE(test2), POINTER :: procptr + + CALL bar (test2) ! { dg-warning "Non-RECURSIVE" } + procptr => test2 ! { dg-warning "Non-RECURSIVE" } + + x = 1812 + END FUNCTION test2 + INTEGER FUNCTION func () ! Using a result variable is ok of course! func = 42 ! { dg-bogus "Non-RECURSIVE" } diff --git a/gcc/testsuite/gfortran.dg/recursive_check_6.f03 b/gcc/testsuite/gfortran.dg/recursive_check_6.f03 new file mode 100644 index 0000000..478539e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/recursive_check_6.f03 @@ -0,0 +1,66 @@ +! { dg-do compile } + +! PR fortran/37779 +! Check that a call to a procedure's containing procedure counts as recursive +! and is rejected if the containing procedure is not RECURSIVE. + +MODULE m + IMPLICIT NONE + +CONTAINS + + SUBROUTINE test_sub () + CALL bar () + CONTAINS + SUBROUTINE bar () + IMPLICIT NONE + PROCEDURE(test_sub), POINTER :: procptr + + CALL test_sub () ! { dg-error "not RECURSIVE" } + procptr => test_sub ! { dg-warning "Non-RECURSIVE" } + CALL foobar (test_sub) ! { dg-warning "Non-RECURSIVE" } + END SUBROUTINE bar + END SUBROUTINE test_sub + + INTEGER FUNCTION test_func () RESULT (x) + x = bar () + CONTAINS + INTEGER FUNCTION bar () + IMPLICIT NONE + PROCEDURE(test_func), POINTER :: procptr + + bar = test_func () ! { dg-error "not RECURSIVE" } + procptr => test_func ! { dg-warning "Non-RECURSIVE" } + CALL foobar (test_func) ! { dg-warning "Non-RECURSIVE" } + END FUNCTION bar + END FUNCTION test_func + + SUBROUTINE sub_entries () + ENTRY sub_entry_1 () + ENTRY sub_entry_2 () + CALL bar () + CONTAINS + SUBROUTINE bar () + CALL sub_entry_1 () ! { dg-error "is not RECURSIVE" } + END SUBROUTINE bar + END SUBROUTINE sub_entries + + INTEGER FUNCTION func_entries () RESULT (x) + ENTRY func_entry_1 () RESULT (x) + ENTRY func_entry_2 () RESULT (x) + x = bar () + CONTAINS + INTEGER FUNCTION bar () + bar = func_entry_1 () ! { dg-error "is not RECURSIVE" } + END FUNCTION bar + END FUNCTION func_entries + + SUBROUTINE main () + CALL test_sub () + CALL sub_entries () + PRINT *, test_func (), func_entries () + END SUBROUTINE main + +END MODULE m + +! { dg-final { cleanup-modules "m" } } |