From 4307649214f90df9a4452acaf4224399066194c6 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Fri, 14 Apr 2017 23:17:52 +0200 Subject: [PATCH] re PR fortran/80361 ([OOP] bogus recursive call to nonrecursive procedure with -fcheck=recursion) 2017-04-14 Janus Weil PR fortran/80361 * class.c (generate_finalization_wrapper): Give the finalization wrapper the recursive attribute. 2017-04-14 Janus Weil PR fortran/80361 * gfortran.dg/class_62.f90: New test case. From-SVN: r246934 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/class.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/class_62.f90 | 29 ++++++++++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/class_62.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9f31ad946d8..0fb826d6ee3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2017-04-14 Janus Weil + + PR fortran/80361 + * class.c (generate_finalization_wrapper): Give the finalization wrapper + the recursive attribute. 2017-04-10 Nicolas Koenig Paul Thomas diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index d507e22ce09..2d72e9570da 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -1613,6 +1613,7 @@ generate_finalization_wrapper (gfc_symbol *derived, gfc_namespace *ns, final->attr.flavor = FL_PROCEDURE; final->attr.function = 1; final->attr.pure = 0; + final->attr.recursive = 1; final->result = final; final->ts.type = BT_INTEGER; final->ts.kind = 4; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3de763f5dc3..107f3dd60b5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-14 Janus Weil + + PR fortran/80361 + * gfortran.dg/class_62.f90: New test case. + 2017-04-14 Andrew Burgess * gcc.target/arc/loop-1.c: New file. diff --git a/gcc/testsuite/gfortran.dg/class_62.f90 b/gcc/testsuite/gfortran.dg/class_62.f90 new file mode 100644 index 00000000000..39ee98dd361 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_62.f90 @@ -0,0 +1,29 @@ +! { dg-do run } +! { dg-options "-fcheck=recursion" } +! +! PR 80361: [5/6/7 Regression] bogus recursive call to nonrecursive procedure with -fcheck=recursion +! +! Contributed by Jürgen Reuter + +program main_ut + + implicit none + + type :: prt_spec_expr_t + end type + + type :: prt_expr_t + class(prt_spec_expr_t), allocatable :: x + end type + + type, extends (prt_spec_expr_t) :: prt_spec_list_t + type(prt_expr_t) :: e + end type + + class(prt_spec_list_t), allocatable :: y + + allocate (y) + allocate (prt_spec_list_t :: y%e%x) + deallocate(y) + +end program -- 2.30.2