]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Fix struct token_and_value odr violation
authorTom de Vries <tdevries@suse.de>
Mon, 14 Aug 2023 16:32:29 +0000 (18:32 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 14 Aug 2023 16:32:29 +0000 (18:32 +0200)
When build gdb with -O2 -flto I run into:
...
gdb/c-exp.y:3003:8: warning: type 'struct token_and_value' violates the C++ \
  One Definition Rule [-Wodr]
 struct token_and_value
        ^
gdb/d-exp.y:1310:8: note: a different type is defined in another translation \
  unit
 struct token_and_value
        ^
...

Fix this by renaming to c_token_and_value and d_token_and_value.

Likewise in gdb/go-exp.y, renaming to go_token_and_value.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR build/22395
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22395

gdb/c-exp.y
gdb/d-exp.y
gdb/go-exp.y

index a8c784142537d0482a4fdfa8cf0e3a564ca6e4ca..032ba25274eefb6c27271caa52dc59b7ff9a7f54 100644 (file)
@@ -3000,7 +3000,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
 }
 
 /* An object of this type is pushed on a FIFO by the "outer" lexer.  */
-struct token_and_value
+struct c_token_and_value
 {
   int token;
   YYSTYPE value;
@@ -3008,7 +3008,7 @@ struct token_and_value
 
 /* A FIFO of tokens that have been read but not yet returned to the
    parser.  */
-static std::vector<token_and_value> token_fifo;
+static std::vector<c_token_and_value> token_fifo;
 
 /* Non-zero if the lexer should return tokens from the FIFO.  */
 static int popping;
@@ -3230,7 +3230,7 @@ classify_inner_name (struct parser_state *par_state,
 static int
 yylex (void)
 {
-  token_and_value current;
+  c_token_and_value current;
   int first_was_coloncolon, last_was_coloncolon;
   struct type *context_type = NULL;
   int last_to_examine, next_to_examine, checkpoint;
@@ -3306,7 +3306,7 @@ yylex (void)
 
   while (next_to_examine <= last_to_examine)
     {
-      token_and_value next;
+      c_token_and_value next;
 
       next = token_fifo[next_to_examine];
       ++next_to_examine;
index b0f2c0d1c10254e05e7589a5aaf236908d6a73a1..8620a67e04a8aee0df74e68e363159b32371f601 100644 (file)
@@ -1307,7 +1307,7 @@ lex_one_token (struct parser_state *par_state)
 }
 
 /* An object of this type is pushed on a FIFO by the "outer" lexer.  */
-struct token_and_value
+struct d_token_and_value
 {
   int token;
   YYSTYPE value;
@@ -1316,7 +1316,7 @@ struct token_and_value
 
 /* A FIFO of tokens that have been read but not yet returned to the
    parser.  */
-static std::vector<token_and_value> token_fifo;
+static std::vector<d_token_and_value> token_fifo;
 
 /* Non-zero if the lexer should return tokens from the FIFO.  */
 static int popping;
@@ -1404,7 +1404,7 @@ classify_inner_name (struct parser_state *par_state,
 static int
 yylex (void)
 {
-  token_and_value current;
+  d_token_and_value current;
   int last_was_dot;
   struct type *context_type = NULL;
   int last_to_examine, next_to_examine, checkpoint;
@@ -1467,7 +1467,7 @@ yylex (void)
 
       while (next_to_examine <= last_to_examine)
        {
-         token_and_value next;
+         d_token_and_value next;
 
          next = token_fifo[next_to_examine];
          ++next_to_examine;
@@ -1531,7 +1531,7 @@ yylex (void)
 
   while (next_to_examine <= last_to_examine)
     {
-      token_and_value next;
+      d_token_and_value next;
 
       next = token_fifo[next_to_examine];
       ++next_to_examine;
index 5c213f138f0f3f150908abdf185832e581e7f02e..92abd95a159bc015069395e9983fac53d2b88538 100644 (file)
@@ -1245,7 +1245,7 @@ lex_one_token (struct parser_state *par_state)
 }
 
 /* An object of this type is pushed on a FIFO by the "outer" lexer.  */
-struct token_and_value
+struct go_token_and_value
 {
   int token;
   YYSTYPE value;
@@ -1253,7 +1253,7 @@ struct token_and_value
 
 /* A FIFO of tokens that have been read but not yet returned to the
    parser.  */
-static std::vector<token_and_value> token_fifo;
+static std::vector<go_token_and_value> token_fifo;
 
 /* Non-zero if the lexer should return tokens from the FIFO.  */
 static int popping;
@@ -1445,11 +1445,11 @@ classify_name (struct parser_state *par_state, const struct block *block)
 static int
 yylex (void)
 {
-  token_and_value current, next;
+  go_token_and_value current, next;
 
   if (popping && !token_fifo.empty ())
     {
-      token_and_value tv = token_fifo[0];
+      go_token_and_value tv = token_fifo[0];
       token_fifo.erase (token_fifo.begin ());
       yylval = tv.value;
       /* There's no need to fall through to handle package.name
@@ -1474,7 +1474,7 @@ yylex (void)
 
   if (next.token == '.')
     {
-      token_and_value name2;
+      go_token_and_value name2;
 
       name2.token = lex_one_token (pstate);
       name2.value = yylval;