Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix building with yacc
@ 2014-02-03 13:51 Mark Kettenis
  2014-02-05  2:13 ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2014-02-03 13:51 UTC (permalink / raw)
  To: gdb-patches

OpenBSD yacc doesn't use YYPRINT, so we end up with gcc complaining
that c_print_token is defined but not used.  As far as I can determine
YYPRINT is a bison-ism, so the diff below wraps c_print_token in
#ifdef YYBISON.

ok?


diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 277242e..b76a06b 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -169,8 +169,10 @@ static struct stoken operator_stoken (const char *);
 static void check_parameter_typelist (VEC (type_ptr) *);
 static void write_destructor_name (struct stoken);
 
+#ifdef YYBISON
 static void c_print_token (FILE *file, int type, YYSTYPE value);
 #define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE)
+#endif
 %}
 
 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly
@@ -3201,10 +3203,12 @@ c_parse (void)
   return result;
 }
 
+#ifdef YYBISON
+
 /* This is called via the YYPRINT macro when parser debugging is
    enabled.  It prints a token's value.  */
 
-static void
+void
 c_print_token (FILE *file, int type, YYSTYPE value)
 {
   switch (type)
@@ -3255,6 +3259,8 @@ c_print_token (FILE *file, int type, YYSTYPE value)
     }
 }
 
+#endif
+
 void
 yyerror (char *msg)
 {


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix building with yacc
  2014-02-03 13:51 [PATCH] Fix building with yacc Mark Kettenis
@ 2014-02-05  2:13 ` Joel Brobecker
  2014-02-05 12:37   ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2014-02-05  2:13 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

Hi Mark,

> OpenBSD yacc doesn't use YYPRINT, so we end up with gcc complaining
> that c_print_token is defined but not used.  As far as I can determine
> YYPRINT is a bison-ism, so the diff below wraps c_print_token in
> #ifdef YYBISON.
> 
> ok?

I don't know bison much to really review the patch, but I think
that you meant c_print_token to remain static, right? (see below)
Aside from that, the change looks OK to me.

ChangeLog?

> diff --git a/gdb/c-exp.y b/gdb/c-exp.y
> index 277242e..b76a06b 100644
> --- a/gdb/c-exp.y
> +++ b/gdb/c-exp.y
> @@ -169,8 +169,10 @@ static struct stoken operator_stoken (const char *);
>  static void check_parameter_typelist (VEC (type_ptr) *);
>  static void write_destructor_name (struct stoken);
>  
> +#ifdef YYBISON
>  static void c_print_token (FILE *file, int type, YYSTYPE value);
>  #define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE)
> +#endif
>  %}
>  
>  %type <voidval> exp exp1 type_exp start variable qualified_name lcurly
> @@ -3201,10 +3203,12 @@ c_parse (void)
>    return result;
>  }
>  
> +#ifdef YYBISON
> +
>  /* This is called via the YYPRINT macro when parser debugging is
>     enabled.  It prints a token's value.  */
>  
> -static void
> +void
>  c_print_token (FILE *file, int type, YYSTYPE value)

I think this "static void" -> "void" will break our build.

>  {
>    switch (type)
> @@ -3255,6 +3259,8 @@ c_print_token (FILE *file, int type, YYSTYPE value)
>      }
>  }
>  
> +#endif
> +
>  void
>  yyerror (char *msg)
>  {

-- 
Joel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix building with yacc
  2014-02-05  2:13 ` Joel Brobecker
@ 2014-02-05 12:37   ` Mark Kettenis
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Kettenis @ 2014-02-05 12:37 UTC (permalink / raw)
  To: brobecker; +Cc: gdb-patches

> Date: Wed, 5 Feb 2014 06:13:12 +0400
> From: Joel Brobecker <brobecker@adacore.com>
> 
> Hi Mark,
> 
> > OpenBSD yacc doesn't use YYPRINT, so we end up with gcc complaining
> > that c_print_token is defined but not used.  As far as I can determine
> > YYPRINT is a bison-ism, so the diff below wraps c_print_token in
> > #ifdef YYBISON.
> > 
> > ok?
> 
> I don't know bison much to really review the patch, but I think
> that you meant c_print_token to remain static, right? (see below)
> Aside from that, the change looks OK to me.

Oops.  Thanks for spotting that.  Below is what I ended up committing:


From 12c5175d68a840960e4cf7d3001c926f15c4d006 Mon Sep 17 00:00:00 2001
From: Mark Kettenis <kettenis@gnu.org>
Date: Wed, 5 Feb 2014 13:30:33 +0100
Subject: [PATCH] Avoid bison-isms when using yacc.

YYPRINT is a bison-ism so c_print_token() ends up being unused when yacc is
used which makes gcc unhappy.  Make sure we only define YYPRINT and
c_print_token() when bison is used to generate the parser.

gdb/ChangeLog:

        * c-exp.y (YYPRINT, c_print_token): Only define if YYBISON is
        defined.
---
 gdb/ChangeLog | 5 +++++
 gdb/c-exp.y   | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a6fa6fc..fcec355 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-05  Mark Kettenis  <kettenis@gnu.org>
+
+	* c-exp.y (YYPRINT, c_print_token): Only define if YYBISON is
+	defined.
+
 2014-02-05  Yao Qi  <yao@codesourcery.com>
 
 	* remote.c (remote_pass_signals): Remove local 'buf' and use
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 277242e..4704845 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -169,8 +169,10 @@ static struct stoken operator_stoken (const char *);
 static void check_parameter_typelist (VEC (type_ptr) *);
 static void write_destructor_name (struct stoken);
 
+#ifdef YYBISON
 static void c_print_token (FILE *file, int type, YYSTYPE value);
 #define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE)
+#endif
 %}
 
 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly
@@ -3201,6 +3203,8 @@ c_parse (void)
   return result;
 }
 
+#ifdef YYBISON
+
 /* This is called via the YYPRINT macro when parser debugging is
    enabled.  It prints a token's value.  */
 
@@ -3255,6 +3259,8 @@ c_print_token (FILE *file, int type, YYSTYPE value)
     }
 }
 
+#endif
+
 void
 yyerror (char *msg)
 {
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-05 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-03 13:51 [PATCH] Fix building with yacc Mark Kettenis
2014-02-05  2:13 ` Joel Brobecker
2014-02-05 12:37   ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox