[1/3] ada-lex: Ignore warnings about register keyword

Message ID 1498412703-24303-2-git-send-email-simon.marchi@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi June 25, 2017, 5:45 p.m. UTC
  Some older versions of flex (such as the one shipped with macOS) generate
code that use the register keyword, which clang warns about.  This patch
makes the compiler ignore those warnings for the portion of the code
generated by flex.

gdb/ChangeLog:

	* common/diagnostics.h (DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER):
	New macro.
	* ada-lex.l: Ignore deprecated register warnings.
---
 gdb/ada-lex.l            | 9 +++++++++
 gdb/common/diagnostics.h | 3 +++
 2 files changed, 12 insertions(+)
  

Comments

Pedro Alves June 26, 2017, 1:13 p.m. UTC | #1
On 06/25/2017 06:45 PM, Simon Marchi wrote:
> Some older versions of flex (such as the one shipped with macOS) generate
> code that use the register keyword, which clang warns about.  This patch
> makes the compiler ignore those warnings for the portion of the code
> generated by flex.

This is fine with me, modulo the "old/older" in comments, since "old"
is a moving target.  Can you add some reference to the actual version
this was observed on?

Thanks,
Pedro Alves
  
Simon Marchi June 26, 2017, 1:39 p.m. UTC | #2
On 2017-06-26 15:13, Pedro Alves wrote:
> On 06/25/2017 06:45 PM, Simon Marchi wrote:
>> Some older versions of flex (such as the one shipped with macOS) 
>> generate
>> code that use the register keyword, which clang warns about.  This 
>> patch
>> makes the compiler ignore those warnings for the portion of the code
>> generated by flex.
> 
> This is fine with me, modulo the "old/older" in comments, since "old"
> is a moving target.  Can you add some reference to the actual version
> this was observed on?

Ok, will do.
  

Patch

diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 0825290..098272f 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -41,6 +41,13 @@  POSEXP  (e"+"?{NUM10})
 
 %{
 
+#include "common/diagnostics.h"
+
+/* Some older versions of flex generate code that uses the "register" keyword,
+   which clang warns about.  */
+DIAGNOSTIC_PUSH
+DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
+
 #define NUMERAL_WIDTH 256
 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1))
 
@@ -648,3 +655,5 @@  dummy_function ada_flex_use[] =
 { 
   (dummy_function) yyunput
 };
+
+DIAGNOSTIC_POP
diff --git a/gdb/common/diagnostics.h b/gdb/common/diagnostics.h
index 5a63bfd..35bacf2 100644
--- a/gdb/common/diagnostics.h
+++ b/gdb/common/diagnostics.h
@@ -33,8 +33,11 @@ 
 
 #ifdef __clang__
 # define DIAGNOSTIC_IGNORE_SELF_MOVE DIAGNOSTIC_IGNORE ("-Wself-move")
+# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER \
+  DIAGNOSTIC_IGNORE ("-Wdeprecated-register")
 #else
 # define DIAGNOSTIC_IGNORE_SELF_MOVE
+# define DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
 #endif
 
 #endif /* COMMON_DIAGNOSTICS_H */