Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb, gdb-18-branch] Ignore Wunused-function in gdb/ada-lex.l
Date: Fri, 20 Nov 2026 11:22:32 +0100	[thread overview]
Message-ID: <20261120102232.894725-1-tdevries@suse.de> (raw)

[ 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


             reply	other threads:[~2026-11-20 10:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:22 Tom de Vries [this message]
2026-11-20 18:54 ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120102232.894725-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox