Hi all,
I just committed a close-to-obvious fix for PR60777 (ok'd by Steve in
the PR), see attachment:
https://gcc.gnu.org/viewcvs?rev=242009&root=gcc&view=rev
Cheers,
Janus
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (Revision 241993)
+++ gcc/fortran/expr.c (Arbeitskopie)
@@ -2794,12 +2794,12 @@ external_spec_function (gfc_expr *e)
return false;
}
- if (f->attr.recursive)
- {
- gfc_error ("Specification function %qs at %L cannot be RECURSIVE",
- f->name, &e->where);
+ /* F08:7.1.11.6. */
+ if (f->attr.recursive
+ && !gfc_notify_std (GFC_STD_F2003,
+ "Specification function '%s' "
+ "at %L cannot be RECURSIVE", f->name, &e->where))
return false;
- }
function_allowed:
return restricted_args (e->value.function.actual);
! { dg-do run }
!
! PR 60777: [F03] RECURSIVE function rejected in specification expression
!
! Contributed by Vladimir Fuka <[email protected]>
module recur
implicit none
contains
pure recursive function f(n) result(answer)
integer, intent(in) :: n
integer :: answer
if (n<2) then
answer = 1
else
answer = f(n-1)*n
end if
end function
pure function usef(n)
integer,intent(in) :: n
character(f(n)) :: usef
usef = repeat('*',f(n))
end function
end module
program testspecexpr
use recur
implicit none
if (usef(1) /= '*') call abort()
if (usef(2) /= '**') call abort()
if (usef(3) /= '******') call abort()
end