Hello Jerry,

This looks OK for both mainline and backporting. I have a question
about the error message in the first chunk:

+   gfc_reduce_init_expr (e);
+   if (e->expr_type != EXPR_CONSTANT)
+     {
+       gfc_error ("STOP code at %L must be a scalar default CHARACTER or "
+ "INTEGER constant expression", &e->where);
+       goto cleanup;
+     }

All that has been tested here is that the expression is constant. That
it be default character or integer is tested afterwards. Surely then,
the message should be:
"STOP code at %L must be a scalar constant expression"?

Thanks for the patch.

Paul

On Thu, 2 Jul 2026 at 16:28, Jerry D <[email protected]> wrote:
>
> See attached patch.
>
> Regression tested on x86_64.
>
> OK for mainline?
>
> Also since this is fixing a rejects valid, I would like to backport.
>
> Regards,
>
> Jerry
> ---
> Expressions used in stop codes can be functions as long as they resolve to
> integer or character.
>
>         PR fortran/126018
>
> gcc/fortran/ChangeLog:
>
>         * match.cc (gfc_match_stopcode): Adjust the f2008 error check.If the
>         STOP code expr type is unknown, do not error. It will be checked in
>         gfc_resolve_code.
>         * resolve.cc (gfc_resolve_code): Add checks for EXEC_STOP and
>         EXEC_ERROR_STOP.
>
> gcc/testsuite/ChangeLog:
>
>         * gfortran.dg/stop_function_code_1.f90: New test.
> ---

Reply via email to