[PATCH] bfd: fix -Wunused errors with clang 13+

Simon Marchi simon.marchi@polymtl.ca
Mon Dec 13 18:52:31 GMT 2021


On 2021-12-03 4:31 p.m., Simon Marchi wrote:
> Clang 13 and 14 produce some -Wunused-but-set-{variable,parameter} for
> situations where gcc doesn't.  In particular, when a variable is set and
> then used in a way to update its own value.  For example, if `i` is only
> used in this way:
> 
>   int i = 2;
>   i++;
>   i = i + 1;
> 
> gcc won't warn, but clang will.
> 
> Fix all such errors found in an --enable-targets=all build.  It would be
> important for somebody who knows what they're doing to just make sure
> that these variables can indeed be deleted, and that there a no cases
> where it's a bug, and the variable should actually be used.
> 
> The first instance of this error fix by this patch is:
> 
>       CC       elf32-score.lo
>     /home/simark/src/binutils-gdb/bfd/elf32-score.c:450:11: error: variable 'relocation' set but not used [-Werror,-Wunused-but-set-variable]
>       bfd_vma relocation;
>               ^
> 
> Change-Id: I2f233ce20352645cf388aff3dfa08a651d21a6b6

Ping.

Simon


More information about the Binutils mailing list