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

Thomas Koenig <[email protected]> Thu, 18 Jun 2026 18:48:45 +0200
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
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 :-)

But it could be an option to not issue the warnings if an error
has already occurred.  What do you (and others) think?

Best regards

	Thomas