Fix build failure with macOS bison

Message ID 20190106164911.22546-1-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Jan. 6, 2019, 4:49 p.m. UTC
  PR gdb/24060 points out a compilation failure of the C parser when it
is built using the macOS system bison.  The bug is a name clash
between the VARIABLE token name and the VARIABLE enumerator in
ui-out.h.

This patch renames VARIABLE in c-exp.y to avoid the clash.  I chose to
rename this identifier because it was the more localized change.

gdb/ChangeLog
2019-01-06  Tom Tromey  <tom@tromey.com>

	PR gdb/24060:
	* c-exp.y (CONV_VAR): Rename from VARIABLE.
---
 gdb/ChangeLog | 5 +++++
 gdb/c-exp.y   | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
  

Comments

Tom Tromey Jan. 6, 2019, 4:50 p.m. UTC | #1
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> PR gdb/24060 points out a compilation failure of the C parser when it
Tom> is built using the macOS system bison.  The bug is a name clash
Tom> between the VARIABLE token name and the VARIABLE enumerator in
Tom> ui-out.h.

Tom> This patch renames VARIABLE in c-exp.y to avoid the clash.  I chose to
Tom> rename this identifier because it was the more localized change.

Tom> gdb/ChangeLog
Tom> 2019-01-06  Tom Tromey  <tom@tromey.com>

Tom> 	PR gdb/24060:
Tom> 	* c-exp.y (CONV_VAR): Rename from VARIABLE.

Simon -- I can't readily try this patch on macOS right now, so I was
hoping you could.

Tom
  
Simon Marchi Jan. 6, 2019, 4:53 p.m. UTC | #2
On 2019-01-06 11:50, Tom Tromey wrote:
> Simon -- I can't readily try this patch on macOS right now, so I was
> hoping you could.

I could tomorrow when I am at work.

Simon
  

Patch

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 155fe09f37..3d7f6a05b5 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -234,7 +234,7 @@  static void c_print_token (FILE *file, int type, YYSTYPE value);
    legal basetypes.  */
 %token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD DOUBLE_KEYWORD
 
-%token <sval> VARIABLE
+%token <sval> CONV_VAR
 
 %token <opcode> ASSIGN_MODIFY
 
@@ -798,7 +798,7 @@  exp	:	FLOAT
 exp	:	variable
 	;
 
-exp	:	VARIABLE
+exp	:	CONV_VAR
 			{
 			  write_dollar_variable (pstate, $1);
 			}
@@ -2884,7 +2884,7 @@  lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
       }
 
   if (*tokstart == '$')
-    return VARIABLE;
+    return CONV_VAR;
 
   if (parse_completion && *lexptr == '\0')
     saw_name_at_eof = 1;
@@ -3337,7 +3337,7 @@  c_print_token (FILE *file, int type, YYSTYPE value)
       break;
 
     case NSSTRING:
-    case VARIABLE:
+    case CONV_VAR:
       parser_fprintf (file, "sval<%s>", copy_name (value.sval));
       break;