* [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register
@ 2024-03-11 16:06 Simon Marchi
2024-03-11 17:49 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2024-03-11 16:06 UTC (permalink / raw)
To: gdb-patches; +Cc: binutils, Simon Marchi
[I'm CCing binutils because it touches include/diagnostics.h, but the
change really only affects GDB, as DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
is only used in GDB.]
When building GDB on Centos 7 (which has flex 2.5.37) and Clang, I get:
$ make ada-exp.o
YACC ada-exp.c
LEX ada-lex.c
CXX ada-exp.o
In file included from /home/smarchi/src/binutils-gdb/gdb/ada-exp.y:1179:
<stdout>:1106:2: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
1106 | register yy_state_type yy_current_state;
| ^~~~~~~~
In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think
that was produced when compiling as C++11, but now that we always compile as
C++17, Clang produces a `-Wregister` error [2].
For GCC, `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` already translates to
ignoring `-Wregister`. So, rename
`DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER` to `DIAGNOSTIC_IGNORE_REGISTER`
and ignore `-Wregister` for Clang too.
[1] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wdeprecated-register
[2] https://releases.llvm.org/17.0.1/tools/clang/docs/DiagnosticsReference.html#wregister
include/ChangeLog:
* diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER): Rename
to...
(DIAGNOSTIC_IGNORE_REGISTER): ... this. Ignore `-Wregister`
instead of `-Wdeprecated-register`.
Change-Id: I8a4a51c7222c68577fa22ecacdddfcba32d9dbc5
---
gdb/ada-lex.l | 10 ++++------
include/diagnostics.h | 11 +++++------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 828ff9a9215a..887527600b32 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -48,13 +48,11 @@ NOT_COMPLETE [^\001]
#include "diagnostics.h"
-/* Some old versions of flex generate code that uses the "register" keyword,
- which clang warns about. This was observed for example with flex 2.5.35,
- as shipped with macOS 10.12. The same happens with flex 2.5.37 and g++ 11
- which defaults to ISO C++17, that does not allow register storage class
- specifiers. */
+/* Some old versions of flex (2.5.x) generate code that uses the "register"
+ keyword, which compilers warn about, because it is not allowed in ISO
+ C++17. */
DIAGNOSTIC_PUSH
-DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
+DIAGNOSTIC_IGNORE_REGISTER
#define NUMERAL_WIDTH 256
#define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1))
diff --git a/include/diagnostics.h b/include/diagnostics.h
index 8cc2b493d2c0..97e30ab807f4 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -53,8 +53,8 @@
# define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS \
DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations")
-# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \
- DIAGNOSTIC_IGNORE ("-Wdeprecated-register")
+# define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister")
+
# if __has_warning ("-Wenum-compare-switch")
# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \
DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
@@ -87,8 +87,7 @@
DIAGNOSTIC_IGNORE ("-Wdeprecated-declarations")
# if __GNUC__ >= 7
-# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \
- DIAGNOSTIC_IGNORE ("-Wregister")
+# define DIAGNOSTIC_IGNORE_REGISTER DIAGNOSTIC_IGNORE ("-Wregister")
# endif
# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
@@ -128,8 +127,8 @@
# define DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
#endif
-#ifndef DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
-# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
+#ifndef DIAGNOSTIC_IGNORE_REGISTER
+# define DIAGNOSTIC_IGNORE_REGISTER
#endif
#ifndef DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
base-commit: b792eb47f25f577ccef365fc9a5c20d55fad42d5
--
2.44.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register
2024-03-11 16:06 [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register Simon Marchi
@ 2024-03-11 17:49 ` Tom Tromey
2024-03-11 17:51 ` Simon Marchi
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2024-03-11 17:49 UTC (permalink / raw)
To: Simon Marchi; +Cc: gdb-patches, binutils
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
Simon> which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think
Simon> that was produced when compiling as C++11, but now that we always compile as
Simon> C++17, Clang produces a `-Wregister` error [2].
Can we just '#define register' in this file or somewhere nearby?
Eventually I'd like to stop using lex for Ada but that's kind of a lot
of work.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register
2024-03-11 17:49 ` Tom Tromey
@ 2024-03-11 17:51 ` Simon Marchi
2024-04-06 3:26 ` Simon Marchi
0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2024-03-11 17:51 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, binutils
On 3/11/24 13:49, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
> Simon> which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think
> Simon> that was produced when compiling as C++11, but now that we always compile as
> Simon> C++17, Clang produces a `-Wregister` error [2].
>
> Can we just '#define register' in this file or somewhere nearby?
We probably can, but ignoring the diagnostic seems safer and less hacky
to me.
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register
2024-03-11 17:51 ` Simon Marchi
@ 2024-04-06 3:26 ` Simon Marchi
2024-04-06 14:40 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Simon Marchi @ 2024-04-06 3:26 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, binutils
On 2024-03-11 13:51, Simon Marchi wrote:
> On 3/11/24 13:49, Tom Tromey wrote:
>>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>>
>> Simon> In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
>> Simon> which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think
>> Simon> that was produced when compiling as C++11, but now that we always compile as
>> Simon> C++17, Clang produces a `-Wregister` error [2].
>>
>> Can we just '#define register' in this file or somewhere nearby?
>
> We probably can, but ignoring the diagnostic seems safer and less hacky
> to me.
>
> Simon
Just stumbled on this. Are you ok with the current patch, or would you
really prefer the #define approach?
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register
2024-04-06 3:26 ` Simon Marchi
@ 2024-04-06 14:40 ` Tom Tromey
2024-04-08 2:58 ` Simon Marchi
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2024-04-06 14:40 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches, binutils
>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
Simon> In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
Simon> which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think
Simon> that was produced when compiling as C++11, but now that we always compile as
Simon> C++17, Clang produces a `-Wregister` error [2].
>>> Can we just '#define register' in this file or somewhere nearby?
>> We probably can, but ignoring the diagnostic seems safer and less hacky
>> to me.
Simon> Just stumbled on this. Are you ok with the current patch, or would you
Simon> really prefer the #define approach?
It's fine if you want to do it. I should really finish my rewrite of
this lexer. IMO flex causes more problems than it solves.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register
2024-04-06 14:40 ` Tom Tromey
@ 2024-04-08 2:58 ` Simon Marchi
0 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2024-04-08 2:58 UTC (permalink / raw)
To: Tom Tromey, Simon Marchi; +Cc: gdb-patches, binutils
On 2024-04-06 10:40, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simon.marchi@efficios.com> writes:
>
> Simon> In ada-lex.l, we already use `DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER`,
> Simon> which for Clang translates to ignoring `-Wdeprecated-register` [1]. I think
> Simon> that was produced when compiling as C++11, but now that we always compile as
> Simon> C++17, Clang produces a `-Wregister` error [2].
>
>>>> Can we just '#define register' in this file or somewhere nearby?
>
>>> We probably can, but ignoring the diagnostic seems safer and less hacky
>>> to me.
>
> Simon> Just stumbled on this. Are you ok with the current patch, or would you
> Simon> really prefer the #define approach?
>
> It's fine if you want to do it. I should really finish my rewrite of
> this lexer. IMO flex causes more problems than it solves.
>
> Tom
Ok, thanks, pushed.
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-04-08 2:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-11 16:06 [PATCH] gdb: ignore -Wregister instead of -Wdeprecated-register Simon Marchi
2024-03-11 17:49 ` Tom Tromey
2024-03-11 17:51 ` Simon Marchi
2024-04-06 3:26 ` Simon Marchi
2024-04-06 14:40 ` Tom Tromey
2024-04-08 2:58 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).