From: Harald Anlauf Date: Mon, 4 Apr 2022 18:42:51 +0000 (+0200) Subject: Fortran: a RECURSIVE procedure cannot be an INTRINSIC X-Git-Tag: releases/gcc-11.3.0~87 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fdaa6de39a5da45dccd06c18dd355893b4cf9060;p=thirdparty%2Fgcc.git Fortran: a RECURSIVE procedure cannot be an INTRINSIC gcc/fortran/ChangeLog: PR fortran/105138 * intrinsic.c (gfc_is_intrinsic): When a symbol refers to a RECURSIVE procedure, it cannot be an INTRINSIC. gcc/testsuite/ChangeLog: PR fortran/105138 * gfortran.dg/recursive_reference_3.f90: New test. Co-authored-by: Steven G. Kargl (cherry picked from commit d46685b04071a485b56de353d997a866bfc8caba) --- diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index a6a18a471e3f..1565ff27fcfb 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -1142,6 +1142,7 @@ gfc_is_intrinsic (gfc_symbol* sym, int subroutine_flag, locus loc) /* Check for attributes which prevent the symbol from being INTRINSIC. */ if (sym->attr.external || sym->attr.contained + || sym->attr.recursive || sym->attr.if_source == IFSRC_IFBODY) return false; diff --git a/gcc/testsuite/gfortran.dg/recursive_reference_3.f90 b/gcc/testsuite/gfortran.dg/recursive_reference_3.f90 new file mode 100644 index 000000000000..f4e2963aec28 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/recursive_reference_3.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-std=f2018" } +! PR fortran/105138 - recursive procedures and shadowing of intrinsics + +RECURSIVE FUNCTION LOG_GAMMA(Z) RESULT(RES) + COMPLEX, INTENT(IN) :: Z + COMPLEX :: RES + RES = LOG_GAMMA(Z) +END FUNCTION LOG_GAMMA + +recursive subroutine date_and_time (z) + real :: z + if (z > 0) call date_and_time (z-1) +end subroutine date_and_time