[binutils-gdb/gdb-18-branch] [gdb, gdb-18-branch] Ignore Wunused-function in gdb/ada-lex.l
Tom de Vries
vries@sourceware.org
Fri Nov 20 19:20:28 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d4d5bf84069c3f6628482dcc1f51fcb1a47a82b0
commit d4d5bf84069c3f6628482dcc1f51fcb1a47a82b0
Author: Tom de Vries <tdevries@suse.de>
Date: Fri Nov 20 20:20:23 2026 +0100
[gdb, gdb-18-branch] Ignore Wunused-function in gdb/ada-lex.l
[ This patch is for the gdb-18-branch. On trunk, commit 8b68f316801 ("Rewrite
the Ada lexer") removes gdb/ada-lex.l, which also solves PR build/35015. ]
In gdb/ada-lex.l, we have the following workaround:
...
/* Dummy definition to suppress warnings about unused static definitions. */
typedef void (*dummy_function) ();
dummy_function ada_flex_use[] =
{
(dummy_function) yyunput
};
...
This stopped working for a range of flex versions (2.6.5 - 2.6.11) which
define yyunput as a macro:
...
#define yyunput(c) yyunput_r(...)
...
[ Version 2.6.12 restores the previous situation using commit 160a160
("fix(skel): restore the flex 2.6.4 yyunput function"). ]
I ran into this on cygwin using 2.6.11.
We can fix this using:
...
#ifdef yyunput
(dummy_function) yyunput_r
#else
(dummy_function) yyunput
#endif
...
but that seems fragile.
We could use "%option nounput". It was added in 2.5.1, but with some bug that
was fixed in 2.5.2. For gdb-18-branch, we (de facto) require >= 2.5.1, and
using "%option nounput" would break support for 2.5.1.
We could use YY_NO_YYUNPUT (available starting 2.6.5) to suppress the
generation of yyunput, while falling back to ada_flex_use for < 2.6.5.
A patch was submitted using this approach [1].
Instead, fix this using a simpler approach: drop ada_flex_use, and ignore the
resulting warning.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=35015
[1] https://sourceware.org/pipermail/gdb-patches/2026-November/231979.html
Diff:
---
gdb/ada-lex.l | 12 +++++-------
include/diagnostics.h | 14 ++++++++++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 65989ebd0a5..4043e92a96d 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -54,6 +54,11 @@ NOT_COMPLETE [^\001]
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_REGISTER
+/* Avoid warnings about unused static function yyunput. We can't use %option
+ nounput because it's broken in flex 2.5.1, and in theory we do support that
+ version. */
+DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
+
#define NUMERAL_WIDTH 256
#define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1))
@@ -753,11 +758,4 @@ rewind_to_char (int ch)
yyrestart (NULL);
}
-/* Dummy definition to suppress warnings about unused static definitions. */
-typedef void (*dummy_function) ();
-dummy_function ada_flex_use[] =
-{
- (dummy_function) yyunput
-};
-
DIAGNOSTIC_POP
diff --git a/include/diagnostics.h b/include/diagnostics.h
index 364789d9af7..70a5f94b7b5 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -73,6 +73,11 @@
DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
# endif
+# if __has_warning ("-Wunused-function")
+# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
+ DIAGNOSTIC_IGNORE ("-Wunused-function")
+# endif
+
# define DIAGNOSTIC_ERROR_SWITCH \
DIAGNOSTIC_ERROR ("-Wswitch")
@@ -101,6 +106,11 @@
DIAGNOSTIC_IGNORE ("-Wunused-but-set-variable")
# endif
+# if __GNUC__ >= 3
+# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
+ DIAGNOSTIC_IGNORE ("-Wunused-function")
+# endif
+
# if __GNUC__ >= 13
# define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
# endif
@@ -150,6 +160,10 @@
# define DIAGNOSTIC_IGNORE_UNUSED_BUT_SET_VARIABLE
#endif
+#ifndef DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
+# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION
+#endif
+
#ifndef DIAGNOSTIC_ERROR_SWITCH
# define DIAGNOSTIC_ERROR_SWITCH
#endif
More information about the Binutils-cvs
mailing list