Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb: Require C++11
Date: Thu, 03 Nov 2016 15:39:00 -0000	[thread overview]
Message-ID: <86twbo7eu6.fsf@gmail.com> (raw)
In-Reply-To: <1477596094-3244-3-git-send-email-palves@redhat.com> (Pedro	Alves's message of "Thu, 27 Oct 2016 20:21:34 +0100")

Pedro Alves <palves@redhat.com> writes:

Hi Pedro,

> to.  The result would be that a make invocation from the build/gdb/
> directory would use "g++ -std=gnu++11" as expected, while a make
> invocation at the top level would not.

This happens to break the build if bison is not new enough (bison 2.6.4),
See details in the patch below,

-- 
Yao (齐尧)
From 9a1e3fb73cc1003eef75b895c6035857494f8ee8 Mon Sep 17 00:00:00 2001
From: Yao Qi <yao.qi@linaro.org>
Date: Thu, 3 Nov 2016 15:33:13 +0000
Subject: [PATCH] Replace YY_NULL with YY_NULLPTR in LANG-exp.c

As we require c++11, GDB fails to build if bison is not new enough.
I see the following error on the system (fedora 19) that bison is
2.6.4,

g++ -std=gnu++11 .... \
	-c -o ada-exp.o -MT ada-exp.o -MMD -MP -MF .deps/ada-exp.Tpo 'if test -f ada-exp.c; then echo ada-exp.c; else echo ../../binutils-gdb/gdb/ada-exp.c; fi`
In file included from ../../binutils-gdb/gdb/ada-exp.y:731:0:
ada-lex.c:113:0: error: "YY_NULL" redefined [-Werror]
 #define YY_NULL 0
 ^
ada-exp.c:158:0: note: this is the location of the previous definition
 #   define YY_NULL nullptr
 ^
cc1plus: all warnings being treated as errors
make: *** [ada-exp.o] Error 1

Both ada-exp.c and ada-lex.c has macro YY_NULL, like this,

 $ cat 1.c
 # ifndef YY_NULL
 #  if defined __cplusplus && 201103L <= __cplusplus
 #   define YY_NULL nullptr
 #  else
 #   define YY_NULL 0
 #  endif
 # endif

 #define YY_NULL 0

as we can see, YY_NULL is defined differently (nullptr vs 0)

$ g++ -std=c++11 -Wall 1.c -c
1.c:9:0: warning: "YY_NULL" redefined
 #define YY_NULL 0
 ^
1.c:3:0: note: this is the location of the previous definition
 #   define YY_NULL nullptr
 ^
$ g++ -Wall 1.c -c

bison renames YY_NULL to YY_NULLPTR in 2013 Nov,
https://lists.gnu.org/archive/html/bison-patches/2013-11/msg00002.html
and bison released later than 2013 Nov have this patch.  Bison 3.0.2,
released on 2013 Dec, is OK.

The fix is to replace YY_NULL with YY_NULLPTR via sed.  With old bison,
YY_NULL becomes YY_NULLPTR; with new bison, YY_NULLPTR becomes
YY_NULLPTRPTR,

gdb:

2016-11-03  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (.y.c): Replace YY_NULL with YY_NULLPTR.

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index d035d8e..6db63c7 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1894,6 +1894,7 @@ po/$(PACKAGE).pot: force
 	     -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \
 	     -e 's/\([ \t;,(]\)free$$/\1xfree/g' \
 	     -e '/^#line.*y.tab.c/d' \
+	     -e 's/YY_NULL/YY_NULLPTR/g' \
 	  < $@.tmp > $@
 	rm -f $@.tmp
 .l.c:


  parent reply	other threads:[~2016-11-03 15:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 19:21 [PATCH 0/2] gdb: Require a C++11 compiler Pedro Alves
2016-10-27 19:21 ` [PATCH 1/2] gdb: Import AX_CXX_COMPILE_STDCXX from the GNU Autoconf Archive Pedro Alves
2016-10-27 19:21 ` [PATCH 2/2] gdb: Require C++11 Pedro Alves
     [not found]   ` <20161028104718.540c10ed@ThinkPad>
2016-10-28  9:03     ` Pedro Alves
2016-10-28 10:44       ` Philipp Rudo
2016-11-03 15:39   ` Yao Qi [this message]
2016-11-03 15:58     ` Pedro Alves
2016-11-03 16:11       ` Yao Qi
2016-10-28 12:07 ` [PATCH 0/2] gdb: Require a C++11 compiler Yao Qi
2016-10-28 15:08   ` Pedro Alves
2016-10-28 17:17     ` [PATCH] gdb/NEWS: Mention C++11 requirement Pedro Alves
2016-10-29  6:13       ` Eli Zaretskii
2016-10-29 15:18         ` Pedro Alves
2016-10-29 15:29           ` Eli Zaretskii
2016-10-29 15:35             ` Pedro Alves
2016-11-01 11:00 ` [PATCH 0/2] gdb: Require a C++11 compiler Richard Earnshaw (lists)
2016-11-01 16:53   ` Pedro Alves
2016-11-02 14:51     ` Richard Earnshaw (lists)
2016-11-02 15:58       ` Pedro Alves
2016-11-04 13:31     ` Maciej W. Rozycki
2016-11-04 14:46       ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86twbo7eu6.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox