From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45261 invoked by alias); 17 Nov 2016 15:05:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 45248 invoked by uid 89); 17 Nov 2016 15:05:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=903, 2358 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Nov 2016 15:04:58 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10E2F8FCEF for ; Thu, 17 Nov 2016 15:04:57 +0000 (UTC) Received: from localhost.localdomain (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAHF4to8013087 for ; Thu, 17 Nov 2016 10:04:56 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] For flex: define YY_FATAL_ERROR, rename fprintf -> parser_fprintf Date: Thu, 17 Nov 2016 15:05:00 -0000 Message-Id: <1479395095-3407-1-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-11/txt/msg00482.txt.bz2 Switching GDB to make use of gnulib's C++ namespace support mode revealed these direct uses of fprintf in the Ada lexer: In file included from ..../src/gdb/ada-exp.y:731:0: ada-lex.c: In function ‘void yy_fatal_error(const char*)’: ada-lex.c:2358:41: error: call to ‘fprintf’ declared with attribute warning: The symbol ::fprintf refers to the system function. Use gnulib::fprintf instead. [-Werror] (void) fprintf( stderr, "%s\n", msg ); ^ yy_fatal_error looks like this: static void yy_fatal_error (yyconst char* msg ) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } We can define YY_FATAL_ERROR to override that default implementation. I think it's a good idea to do that and call internal_error instead of exiting gdb. However, the default implementation is still unconditionally compiled in, so we need to handle that fprintf somehow too. gnulib's C++ namespace support adds that useful warning shown above, breaking the build if we don't do anything here. So this commit uses sed to replace fprintf calls with parser_fprintf calls, like we already do to rewire malloc to xmalloc, etc. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * Makefile.in (.l.c): Replace fprintf calls with parser_fprintf calls. * yy-remap.h (YY_FATAL_ERROR): Define. --- gdb/Makefile.in | 14 ++++++++++---- gdb/yy-remap.h | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 3876cd9..c473472 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1875,10 +1875,15 @@ po/$(PACKAGE).pot: force # LANG-exp.c is generated in objdir from LANG-exp.y if it doesn't # exist in srcdir, then compiled in objdir to LANG-exp.o. If we # said LANG-exp.c rather than ./c-exp.c some makes would -# sometimes re-write it into $(srcdir)/c-exp.c. Remove bogus -# decls for malloc/realloc/free which conflict with everything else. -# Strictly speaking c-exp.c should therefore depend on -# Makefile.in, but that was a pretty big annoyance. +# sometimes re-write it into $(srcdir)/c-exp.c. +# +# Remove bogus decls for malloc/realloc/free which conflict with +# everything else. +# +# Replace calls to fprintf in order to redirect stderr -> gdb_stderr. +# +# Strictly speaking c-exp.c should therefore depend on Makefile.in, +# but that was a pretty big annoyance. .SUFFIXES: .y .l .y.c: @@ -1909,6 +1914,7 @@ po/$(PACKAGE).pot: force -e 's/\([^x]\)realloc/\1xrealloc/g' \ -e 's/\([ \t;,(]\)free\([ \t]*[&(),]\)/\1xfree\2/g' \ -e 's/\([ \t;,(]\)free$$/\1xfree/g' \ + -e 's/\([ \t;,(]\)fprintf/\1parser_fprintf/g' \ -e 's/yy_flex_xrealloc/yyxrealloc/g' \ < $@ > $@.new && \ rm -f $@ && \ diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h index 71fa946..d96f8e6 100644 --- a/gdb/yy-remap.h +++ b/gdb/yy-remap.h @@ -90,3 +90,5 @@ #endif #define YYFPRINTF parser_fprintf + +#define YY_FATAL_ERROR(msg) internal_error (__FILE__, __LINE__, msg) -- 2.5.5