https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105138
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #9 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #8)
> This patch fixes the error. The comment in the patch explains it.
Good catch, Steve.
I think this can (and needs to) be simplified further. :-)
First, the check on sym->result should not be necessary, as it looks redundant.
Second, we need to handle recursive subroutines, such as:
recursive subroutine date_and_time (z)
real :: z
if (z > 0) call date_and_time (z-1)
end subroutine date_and_time
Thus we could combine the second part of the condition in your patch with
the code preceding it:
diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc
index 2339d9050ec..e89131f5a71 100644
--- a/gcc/fortran/intrinsic.cc
+++ b/gcc/fortran/intrinsic.cc
@@ -1164,6 +1164,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;
This regtests OK for me.