[PATCH 4/4] gdb: Suppress "unused" variable warning on Clang

Tsukasa OI research_trasio@irq.a4lg.com
Thu Sep 15 03:10:26 GMT 2022


Clang generates a warning if there is a variable which is written but not
read thereafter.  By the default configuration (with "-Werror"), it causes a
build failure (unless "--disable-werror" is specified).

Because the cause of this error is in the Bison-generated code
($(binutils)/gdb/cp-name-parser.y -> $(srcdir)/gdb/cp-name-parser.c),
this commit suppresses this warning ("-Wunused-but-set-variable") by placing
the DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE macro at the end of user
prologue on cp-name-parser.y.

gdb/ChangeLog:

	* cp-name-parser.y: Suppress -Wunused-but-set-variable warning on
	the Bison-generated code.
---
 gdb/cp-name-parser.y | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 34c691ddabb..21ba51679d3 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -248,6 +248,10 @@ cpname_state::make_name (const char *name, int len)
 
 static int yylex (YYSTYPE *, cpname_state *);
 static void yyerror (cpname_state *, const char *);
+
+#include "diagnostics.h"
+DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
+
 %}
 
 %type <comp> exp exp1 type start start_opt oper colon_name
-- 
2.34.1



More information about the Gdb-patches mailing list