Re: [patch, fortran] Mark variables in references for variable definition context as used.

Mikael Morin <[email protected]> Thu, 18 Jun 2026 19:14:58 +0200
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
Le 18/06/2026 à 18:48, Thomas Koenig a écrit :
> Hi Mikael,
> 
>>> +
>>> +/* Mark the variable of an expression in a vardef context as
>>> +   set and mark everything in the references as used.  */
>>> +
>>> +void
>>> +gfc_expr_set_at (gfc_expr *expr, locus *loc, enum value_set how_set)
>>> +{
>>> +  enum value_used prev_used;
>>> +  gfc_symbol *sym;
>>> +  locus prev_loc;
>>> +
>>> +  if (!expr)
>>> +    return;
>>> +
>>> +  if (expr->expr_type != EXPR_VARIABLE)
>>> +    return;
>> Don't you need to call gfc_value_used_expr in all cases, including for 
>> non-variables?  If I'm understanding well, we are in invalid code 
>> territory here, but avoiding a cascade of uninitialized diagnostics 
>> remains worth pursuing?
> 
> Without this check, I got a few ICEs during development of the patch.
> Test testsuite has a lot of invalid code (which it tests for :-)
> 
No no, my comment was not about removing this check, it was about 
keeping the condition but skipping only the gfc_value_set_at part of the 
function (and all the business around the variable symbol) if true.

> But it could be an option to not issue the warnings if an error
> has already occurred.  What do you (and others) think?
> 
Well, if my suggestion above doesn't work, sounds like an acceptable 
solution to me.