From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4279 invoked by alias); 11 Dec 2008 21:37:05 -0000 Received: (qmail 4268 invoked by uid 22791); 11 Dec 2008 21:37:05 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Dec 2008 21:36:29 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mBBLaSrg003323 for ; Thu, 11 Dec 2008 16:36:28 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mBBLaRM2015762; Thu, 11 Dec 2008 16:36:27 -0500 Received: from opsy.redhat.com (vpn-12-219.rdu.redhat.com [10.11.12.219]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mBBLaQWJ030860; Thu, 11 Dec 2008 16:36:26 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 85AC5508027; Thu, 11 Dec 2008 14:36:25 -0700 (MST) To: gdb-patches@sourceware.org Subject: RFA: fix macro expansion bug From: Tom Tromey Reply-To: tromey@redhat.com Date: Thu, 11 Dec 2008 21:37:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 X-SW-Source: 2008-12/txt/msg00212.txt.bz2 This patch fixes a macro expansion bug pointed out by Pedro. The bug is that get_pp_number incorrectly handles pp-number tokens starting with '.'. According to the C standard, it ought to only accept '.' followed by a digit at the beginning of a pp-number. However, it unconditionally accepts a leading '.'. Built and regtested on x86-64 (compile farm). Test case included. Please review. Tom 2008-12-11 Tom Tromey * macroexp.c (get_pp_number): Require digit after leading ".". 2008-12-11 Tom Tromey * gdb.base/macscp.exp: New regression test. diff --git a/gdb/macroexp.c b/gdb/macroexp.c index 7fb23ce..982df4d 100644 --- a/gdb/macroexp.c +++ b/gdb/macroexp.c @@ -278,7 +278,9 @@ get_pp_number (struct macro_buffer *tok, char *p, char *end) { if (p < end && (macro_is_digit (*p) - || *p == '.')) + || (*p == '.' + && p + 2 <= end + && macro_is_digit (p[1])))) { char *tok_start = p; diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index 9cb9ef5..40021b9 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -652,3 +652,11 @@ gdb_test "print str(maude)" \ gdb_test "print xstr(maude)" \ " = \"5\"" \ "stringify with substitution" + +# Regression test for pp-number bug. +gdb_test "macro define si_addr fields.fault.si_addr" \ + "" \ + "define si_addr macro" +gdb_test "macro expand siginfo.si_addr" \ + "expands to: siginfo. fields.fault.si_addr" \ + "macro expand siginfo.si_addr"