Skip to content

Commit

Permalink
gdb: Suppress "unused" variable warning on Clang
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
a4lg committed Sep 18, 2022
1 parent 3abd1e8 commit 2ae1804
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gdb/cp-name-parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2ae1804

Please sign in to comment.