public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-10746] Fortran: a RECURSIVE procedure cannot be an INTRINSIC
@ 2022-05-16 19:39 Harald Anlauf
  0 siblings, 0 replies; only message in thread
From: Harald Anlauf @ 2022-05-16 19:39 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d31975be113562448520f4c94fc75b9cbb09715e

commit r10-10746-gd31975be113562448520f4c94fc75b9cbb09715e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Apr 4 20:42:51 2022 +0200

    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 <kargl@gcc.gnu.org>
    (cherry picked from commit d46685b04071a485b56de353d997a866bfc8caba)

Diff:
---
 gcc/fortran/intrinsic.c                             |  1 +
 gcc/testsuite/gfortran.dg/recursive_reference_3.f90 | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index efe79a9bec6..958a319e2aa 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -1138,6 +1138,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 00000000000..f4e2963aec2
--- /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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-16 19:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 19:39 [gcc r10-10746] Fortran: a RECURSIVE procedure cannot be an INTRINSIC Harald Anlauf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).