From patchwork Fri Jan 30 09:23:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 434784 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1650914017B for ; Fri, 30 Jan 2015 20:26:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=x0P6IOpk/fNo2NkhkOBw6/rvnsaoZzG8cQndMhl6xN+K4al9UX Fu+xB0wuytXifVFnI4xYGernjJeTK9pv+zSILKxvOt1IcK6X3wyXYWUIlapm0Azp 6gWbGQxJ+T/VUIGj0vQmXv+RY/rfRyhacGKgUOp280PhsMn29e7EaYicA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=SYSM9Qa5VJ0l0VI+G78/7MsWKx8=; b=c0C3HjdPBRYX+RiiMM4n 8E43WJ+LQLjwwOvxn9jCrjnEVgOVPwOWVVTBFaW9Yrt8p79jf4jLbrlrJoCWlkqm xgjzLDetnj8oQQS1IMjo3YUgbnbiTFB9nbnRfkh8EdJKBpHByUfaJPbVQQOjaCaD E820T8wDsO5DBcPajVbNlBM= Received: (qmail 12192 invoked by alias); 30 Jan 2015 09:23:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12158 invoked by uid 89); 30 Jan 2015 09:23:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 30 Jan 2015 09:23:17 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0U9NGXT014769 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 30 Jan 2015 04:23:16 -0500 Received: from localhost (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0U9NEqh017609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Jan 2015 04:23:15 -0500 Received: by localhost (Postfix, from userid 1001) id 76FD71A0282; Fri, 30 Jan 2015 10:23:13 +0100 (CET) From: Dodji Seketeli To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek , Jason Merrill , Tom Tromey Subject: [PATCH, libcpp] Do not modify a token once it has been initialized X-URL: http://www.redhat.com Date: Fri, 30 Jan 2015 10:23:13 +0100 Message-ID: <86oapg1v26.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Hello, While looking at PR preprocessor/64803, I noticed that builtin_macro was changing the location a token after it was been handed out by _cpp_lex_direct(). Use the combination of cpp_force_token_locations() and cpp_stop_forcing_token_locations() that are intended for exactly that use case. Boostrapped and tested on x86_64-unknown-linux-gnu. libcpp/ChangeLog: * macro.c (builtin_macro): Use the combination of cpp_force_token_locations() and cpp_stop_forcing_token_locations() instead of modifying the location of the token after its initialization. OK to for trunk when stage 1 re-opens? Cheers, Signed-off-by: Dodji Seketeli --- libcpp/macro.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libcpp/macro.c b/libcpp/macro.c index 9571345..ca199ba 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -442,9 +442,12 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node, source_location loc) /* Set pfile->cur_token as required by _cpp_lex_direct. */ pfile->cur_token = _cpp_temp_token (pfile); + /* force the location of the token emitted by _cpp_lex_direct() to + have the location LOC. */ + cpp_force_token_locations (pfile, &loc); cpp_token *token = _cpp_lex_direct (pfile); - /* We should point to the expansion point of the builtin macro. */ - token->src_loc = loc; + cpp_stop_forcing_token_locations (pfile); + if (pfile->context->tokens_kind == TOKENS_KIND_EXTENDED) { /* We are tracking tokens resulting from macro expansion.