Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb, gdb-18-branch] Ignore Wunused-function in gdb/ada-lex.l
@ 2026-11-20 10:22 Tom de Vries
  2026-11-20 18:54 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2026-11-20 10:22 UTC (permalink / raw)
  To: gdb-patches

[ 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.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=35015

[1] https://sourceware.org/pipermail/gdb-patches/2026-November/231979.html
---
 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

base-commit: d194937d78941445a61758cbf12c7b36e672ac7e
-- 
2.51.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 10:22 [PATCH] [gdb, gdb-18-branch] Ignore Wunused-function in gdb/ada-lex.l Tom de Vries
2026-11-20 18:54 ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox