From patchwork Sun Dec 19 07:38:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 76114 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]) by ozlabs.org (Postfix) with SMTP id 0DB87B70A3 for ; Sun, 19 Dec 2010 18:40:46 +1100 (EST) Received: (qmail 13685 invoked by alias); 19 Dec 2010 07:40:42 -0000 Received: (qmail 13628 invoked by uid 22791); 19 Dec 2010 07:40:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 19 Dec 2010 07:40:35 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 63EC3CB02E9; Sun, 19 Dec 2010 08:40:33 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HK2TeIeYO+WX; Sun, 19 Dec 2010 08:40:33 +0100 (CET) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 3C1DBCB02DE; Sun, 19 Dec 2010 08:40:33 +0100 (CET) From: Eric Botcazou To: Jakub Jelinek Subject: Re: [PATCH] Fix -traditional-cpp preprocessing (PR preprocessor/39213) Date: Sun, 19 Dec 2010 08:38:35 +0100 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org, Tom Tromey References: <20101217194500.GE2198@tyan-ft48-01.lab.bos.redhat.com> In-Reply-To: <20101217194500.GE2198@tyan-ft48-01.lab.bos.redhat.com> MIME-Version: 1.0 Message-Id: <201012190838.35674.ebotcazou@adacore.com> 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 > This patch adds the same test to traditional preprocessing. I've > bootstrapped/regtested it on x86_64-linux and i686-linux and tries to > preprocess a couple of large files with -traditional-cpp without any > difference, but I can't reproduce the original problem. CCing > Eric who has managed to reproduce it on Solaris. As explained in the audit trail, the patch doesn't work because calls to _cpp_overlay_buffer and _cpp_remove_overlay are unbalanced in the presence of #pragma redefine_extname, so the attached hunk is also needed. In fact, it is even sufficient to fix the problem, without the traditional.c hunk. Tested on sparc64-sun-solaris2.9 and i586-suse-linux. OK for mainline and 4.5/4.4 branches? If so, which version? 2010-12-19 Eric Botcazou Jakub Jelinek PR preprocessor/39213 * directives.c (end_directive): Call _cpp_remove_overlay for deferred pragmas as well in traditional mode. * traditional.c (_cpp_scan_out_logical_line): Don't call _cpp_process_line_notes if pfile->overlaid_buffer. Index: directives.c =================================================================== --- directives.c (revision 167901) +++ directives.c (working copy) @@ -281,16 +281,17 @@ start_directive (cpp_reader *pfile) static void end_directive (cpp_reader *pfile, int skip_line) { - if (pfile->state.in_deferred_pragma) - ; - else if (CPP_OPTION (pfile, traditional)) + if (CPP_OPTION (pfile, traditional)) { /* Revert change of prepare_directive_trad. */ - pfile->state.prevent_expansion--; + if (!pfile->state.in_deferred_pragma) + pfile->state.prevent_expansion--; if (pfile->directive != &dtable[T_DEFINE]) _cpp_remove_overlay (pfile); } + else if (pfile->state.in_deferred_pragma) + ; /* We don't skip for an assembler #. */ else if (skip_line) { Index: traditional.c =================================================================== --- traditional.c (revision 167901) +++ traditional.c (working copy) @@ -1,5 +1,5 @@ /* CPP Library - traditional lexical analysis and macro expansion. - Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009 + Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by Neil Booth, May 2002 @@ -378,7 +378,8 @@ _cpp_scan_out_logical_line (cpp_reader * for (;;) { if (!context->prev - && cur >= pfile->buffer->notes[pfile->buffer->cur_note].pos) + && cur >= pfile->buffer->notes[pfile->buffer->cur_note].pos + && !pfile->overlaid_buffer) { pfile->buffer->cur = cur; _cpp_process_line_notes (pfile, false);