Re: [PATCH] fortran: [PR126018] Fix rejects character function invocation, as stop code

Jerry D <[email protected]> Thu, 2 Jul 2026 13:18:16 -0700
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
On 7/2/26 8:49 AM, Paul Richard Thomas wrote:
> 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"?

I can agree, I simply kept the original wording. I will make that change and 
make sure it does not wiggle on the testsuite somewhere.

Thanks,

Jerry

> 
> 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.
>> ---