This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] fixes for functions
Hi Daniel,
Daniel Franke wrote:
> + /* A function, that is not a statement-function, shall not have an initializer. */
> + if (sym->attr.function && sym->value && sym->attr.proc != PROC_ST_FUNCTION)
> + {
> + gfc_error ("Function '%s' at %L cannot have an initializer",
>
I think one cannot really say that a statement function has an
initializer; it does not act like an initializer and the standard does
call it "scalar-expr" and not initializer.
Additionally, I would personally not use a comment at all as I regard
the if statement plus the error message as self documenting.
Lacking better ideas I leave it to you whether you check it in as is,
without the comment or with a better ;-) comment.
This patch is OK.
Note: This patch only fixes one part of PR 31639. The original test case
gives still an ICE. It should give an error similarly to NAG f95:
Error: bb.f90, line 5: Initialisation expression for N1 is not constant
And also
function f()
integer :: i = irand()
f = i
end function
gives still gives an ICE.
(Intel: "This ... function ... is invalid in constant expressions")
Tobias