[05/11] intl: Fix clang -Wunused-but-set-variable on plural.c

Message ID 20221028173532.876027-6-adhemerval.zanella@linaro.org
State Committed
Commit 6ee5a9767a245455720d39eeaa3ce136825e8a42
Headers
Series Initial fixes for clang build support |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella Netto Oct. 28, 2022, 5:35 p.m. UTC
  Clang warns that '__gettextnerrs' set but not used:

  intl/plural.c:1034:9: error: variable '__gettextnerrs' set but not used
  [-Werror,-Wunused-but-set-variable]
      int yynerrs = 0;
        ^

Since the file is auto-generated, suppress the warning with a compiler
flag.
---
 intl/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Fangrui Song Oct. 29, 2022, 12:44 a.m. UTC | #1
On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>Clang warns that '__gettextnerrs' set but not used:
>
>  intl/plural.c:1034:9: error: variable '__gettextnerrs' set but not used
>  [-Werror,-Wunused-but-set-variable]
>      int yynerrs = 0;
>        ^
>
>Since the file is auto-generated, suppress the warning with a compiler
>flag.
>---
> intl/Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/intl/Makefile b/intl/Makefile
>index 315c75a18f..1c3b2a2273 100644
>--- a/intl/Makefile
>+++ b/intl/Makefile
>@@ -154,7 +154,8 @@ $(objpfx)tst-gettext5.out: $(objpfx)tst-gettext.out
> $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out
>
> CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \
>-	    -D'LOCALE_ALIAS_PATH="$(localedir)"'
>+	    -D'LOCALE_ALIAS_PATH="$(localedir)"' \
>+	    -Wno-unused-but-set-variable
> BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output
>
> $(inst_localedir)/locale.alias: locale.alias $(+force)
>-- 
>2.34.1
>

yynerrs is incremented but its value is unused.
Clang 15 (https://reviews.llvm.org/D122271) -Wunused-but-set-variable
gives a warning while GCC doesn't.
-Wunused-but-set-variable is available in GCC 4.6, smaller than the minimum required version 6.2.

Reviewed-by: Fangrui Song <maskray@google.com>
  
Adhemerval Zanella Netto Oct. 31, 2022, 7:54 p.m. UTC | #2
On 28/10/22 21:44, Fangrui Song wrote:
> On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>> Clang warns that '__gettextnerrs' set but not used:
>>
>>  intl/plural.c:1034:9: error: variable '__gettextnerrs' set but not used
>>  [-Werror,-Wunused-but-set-variable]
>>      int yynerrs = 0;
>>        ^
>>
>> Since the file is auto-generated, suppress the warning with a compiler
>> flag.
>> ---
>> intl/Makefile | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/intl/Makefile b/intl/Makefile
>> index 315c75a18f..1c3b2a2273 100644
>> --- a/intl/Makefile
>> +++ b/intl/Makefile
>> @@ -154,7 +154,8 @@ $(objpfx)tst-gettext5.out: $(objpfx)tst-gettext.out
>> $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out
>>
>> CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \
>> -        -D'LOCALE_ALIAS_PATH="$(localedir)"'
>> +        -D'LOCALE_ALIAS_PATH="$(localedir)"' \
>> +        -Wno-unused-but-set-variable
>> BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output
>>
>> $(inst_localedir)/locale.alias: locale.alias $(+force)
>> -- 
>> 2.34.1
>>
> 
> yynerrs is incremented but its value is unused.
> Clang 15 (https://reviews.llvm.org/D122271) -Wunused-but-set-variable
> gives a warning while GCC doesn't.
> -Wunused-but-set-variable is available in GCC 4.6, smaller than the minimum required version 6.2.

I will add this on commit message.

> 
> Reviewed-by: Fangrui Song <maskray@google.com>

Thanks.
  

Patch

diff --git a/intl/Makefile b/intl/Makefile
index 315c75a18f..1c3b2a2273 100644
--- a/intl/Makefile
+++ b/intl/Makefile
@@ -154,7 +154,8 @@  $(objpfx)tst-gettext5.out: $(objpfx)tst-gettext.out
 $(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out
 
 CPPFLAGS += -D'LOCALEDIR="$(localedir)"' \
-	    -D'LOCALE_ALIAS_PATH="$(localedir)"'
+	    -D'LOCALE_ALIAS_PATH="$(localedir)"' \
+	    -Wno-unused-but-set-variable
 BISONFLAGS = --yacc --no-lines --name-prefix=__gettext --output
 
 $(inst_localedir)/locale.alias: locale.alias $(+force)