From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5542 invoked by alias); 19 Jul 2011 17:38:16 -0000 Received: (qmail 5470 invoked by uid 22791); 19 Jul 2011 17:38:15 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jul 2011 17:38:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6JHbUK9024611 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 19 Jul 2011 13:37:30 -0400 Received: from localhost (ovpn-113-141.phx2.redhat.com [10.3.113.141]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6JHbTUs023229 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 19 Jul 2011 13:37:30 -0400 Received: by localhost (Postfix, from userid 500) id 533A329C043; Tue, 19 Jul 2011 19:37:28 +0200 (CEST) From: Dodji Seketeli To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, tromey@redhat.com, gdr@integrable-solutions.net, joseph@codesourcery.com, burnus@net-b.de, charlet@act-europe.fr, bonzini@gnu.org Subject: Re: [PATCH 1/7] Linemap infrastructure for virtual locations References: <1291979498-1604-1-git-send-email-dodji@redhat.com> <3d6fbfd16f0e3493839205de1266eaaa8dbb9c77.1310824121.git.dodji@redhat.com> <4E249A5C.9060409@redhat.com> <4E25B358.9090700@redhat.com> X-URL: http://www.redhat.com Date: Tue, 19 Jul 2011 18:03:00 -0000 In-Reply-To: <4E25B358.9090700@redhat.com> (Jason Merrill's message of "Tue, 19 Jul 2011 12:39:52 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg01551.txt.bz2 Jason Merrill writes: > On 07/19/2011 05:42 AM, Dodji Seketeli wrote: >> If you are talking about the case of a macro A that can have (among the >> tokens of its replacement list) a token B that itself is a macro, then >> this is supported by the current setup. > > I was more thinking of the case of a macro A with a parameter X which > is passed to macro B, and then macro C: > > 1: #define A(X) B(X) > 2: #define B(X) C(X) > 3: #define C(X) X+2 > 4: > 5: A(blah) So, let's consider a similar example then: $ cat -n test12.c=20 1 int var; 2 #define A(X) B(X) 3 #define B(X) C(X) 4 #define C(X) 2+X 5=09 6 int 7 foo (void) 8 { 9 return A(blah()); 10 } $ ./cc1 -ftrack-macro-expansion -quiet ../../prtests/test12.c test12.c: In function =E2=80=98foo=E2=80=99: test12.c:9:15: erreur: called object =E2=80=98var=E2=80=99 is not a function test12.c:4:16: note: in expansion of macro 'C' test12.c:3:14: note: expanded from here test12.c:3:16: note: in expansion of macro 'B' test12.c:2:14: note: expanded from here test12.c:2:16: note: in expansion of macro 'A' test12.c:9:10: note: expanded from here > > what is the replacement point of "blah"? Is it the use of X on line > 3? There are going to be 3 macro expansions happening successively. Eventually, in the context of the expansion of C (indirectly triggered by the expansion of A), yes, the replacement point of "blah" is going to be the use of X at line 3. On my example, the corresponds to the diagnostic line: test12.c:4:16: note: in expansion of macro 'C' > It seems that we can only have information about the X in one of > the macro definitions. That is true, in the context of a given macro expansion, e.g, in the context of the expansion of the macro A, in A(blah). But then, when libcpp is requested to get the next token (e.g, after expanding A(blah) into B(blah)) it finds out that the next token B is a macro itself. It then expands that macro in a new expansion context. So we have information about the X in the context of B. We eventually reach the expansion context of C that way. --=20 Dodji