nvptx: Silence unused variable warning

Message ID 20220828110925.gxuejmyvilvqy66h@lug-owl.de
State New, archived
Headers
Series nvptx: Silence unused variable warning |

Commit Message

Jan-Benedict Glaw Aug. 28, 2022, 11:09 a.m. UTC
  Hi!

The nvptx backend defines ASM_OUTPUT_DEF along with
ASM_OUTPUT_DEF_FROM_DECLS.  Much like the rs6000 coff target, nvptx
triggers an unused variable warning:

/usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o varasm.o -MT varasm.o -MMD -MP -MF ./.deps/varasm.TPo ../../gcc/gcc/varasm.cc
../../gcc/gcc/varasm.cc: In function 'void output_constant_pool_contents(rtx_constant_pool*)':
../../gcc/gcc/varasm.cc:4318:21: error: unused variable 'name' [-Werror=unused-variable]
 4318 |         const char *name = XSTR (desc->sym, 0);
      |                     ^~~~
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:1145: varasm.o] Error 1


Fixed the same way:



Ok for HEAD?

Thanks,
  Jan-Benedict

--
  

Comments

Jeff Law Aug. 31, 2022, 3:41 p.m. UTC | #1
On 8/28/2022 5:09 AM, Jan-Benedict Glaw wrote:
> Hi!
>
> The nvptx backend defines ASM_OUTPUT_DEF along with
> ASM_OUTPUT_DEF_FROM_DECLS.  Much like the rs6000 coff target, nvptx
> triggers an unused variable warning:
>
> /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o varasm.o -MT varasm.o -MMD -MP -MF ./.deps/varasm.TPo ../../gcc/gcc/varasm.cc
> ../../gcc/gcc/varasm.cc: In function 'void output_constant_pool_contents(rtx_constant_pool*)':
> ../../gcc/gcc/varasm.cc:4318:21: error: unused variable 'name' [-Werror=unused-variable]
>   4318 |         const char *name = XSTR (desc->sym, 0);
>        |                     ^~~~
> cc1plus: all warnings being treated as errors
> make[1]: *** [Makefile:1145: varasm.o] Error 1
>
>
> Fixed the same way:
>
> diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
> index ed72c253191..71297440566 100644
> --- a/gcc/config/nvptx/nvptx.h
> +++ b/gcc/config/nvptx/nvptx.h
> @@ -321,6 +321,9 @@ struct GTY(()) machine_function
>   #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)	\
>     do						\
>       {						\
> +      (void) (FILE);				\
> +      (void) (LABEL1);				\
> +      (void) (LABEL2);				\
>         gcc_unreachable ();			\
>       }						\
>     while (0)
>
>
> Ok for HEAD?
OK with a ChangeLog entry.

jeff
  
Tom de Vries Sept. 6, 2022, 10:41 a.m. UTC | #2
On 8/28/22 13:09, Jan-Benedict Glaw wrote:
> Hi!
> 
> The nvptx backend defines ASM_OUTPUT_DEF along with
> ASM_OUTPUT_DEF_FROM_DECLS.  Much like the rs6000 coff target, nvptx
> triggers an unused variable warning:
> 
> /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o varasm.o -MT varasm.o -MMD -MP -MF ./.deps/varasm.TPo ../../gcc/gcc/varasm.cc
> ../../gcc/gcc/varasm.cc: In function 'void output_constant_pool_contents(rtx_constant_pool*)':
> ../../gcc/gcc/varasm.cc:4318:21: error: unused variable 'name' [-Werror=unused-variable]
>   4318 |         const char *name = XSTR (desc->sym, 0);
>        |                     ^~~~
> cc1plus: all warnings being treated as errors
> make[1]: *** [Makefile:1145: varasm.o] Error 1
> 
> 
> Fixed the same way:
> 
> diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
> index ed72c253191..71297440566 100644
> --- a/gcc/config/nvptx/nvptx.h
> +++ b/gcc/config/nvptx/nvptx.h
> @@ -321,6 +321,9 @@ struct GTY(()) machine_function
>   #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)	\
>     do						\
>       {						\
> +      (void) (FILE);				\
> +      (void) (LABEL1);				\
> +      (void) (LABEL2);				\
>         gcc_unreachable ();			\
>       }						\
>     while (0)
> 
> 
> Ok for HEAD?
> 

LGTM.

Thanks,
- Tom
  

Patch

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index ed72c253191..71297440566 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -321,6 +321,9 @@  struct GTY(()) machine_function
 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)	\
   do						\
     {						\
+      (void) (FILE);				\
+      (void) (LABEL1);				\
+      (void) (LABEL2);				\
       gcc_unreachable ();			\
     }						\
   while (0)