From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25819 invoked by alias); 16 Jul 2014 10:34:16 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25756 invoked by uid 55); 16 Jul 2014 10:34:12 -0000 From: "dodji at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/60723] Line directives with incorrect system header flag Date: Wed, 16 Jul 2014 10:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: preprocessor X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dodji at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dodji at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg01061.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60723 --- Comment #21 from Dodji Seketeli --- Author: dodji Date: Wed Jul 16 10:33:36 2014 New Revision: 212638 URL: https://gcc.gnu.org/viewcvs?rev=212638&root=gcc&view=rev Log: PR preprocessor/60723 - missing system-ness marks for macro tokens When a system macro is expanded in a non-system file during out-of-line preprocessing, it can happen that the preprocessor forgets to emit line markers to express the system-ness status of tokens that come after the expansion of the macro. That can lead to situations where the entire non-system file can be considered as being a system file and thus have its warnings be discarded during the compilation of the resulting preprocessed file. My understanding is that this is due to the preprocessor not systematically detecting (and reporting) the change in system-ness of tokens. And this is what this patch does. Each time the system-ness of a given token is different from the previous token that was emitted by the preprocessor, it emits a line marker for the sole purpose of marking the new system-ness of the subsequent tokens to come. Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/c-family/ChangeLog: * c-ppoutput.c (struct print::prev_was_system_token): New data member. (init_pp_output): Initialize it. (maybe_print_line_1, maybe_print_line, print_line_1, print_line) (do_line_change): Return a flag saying if a line marker was emitted or not. (scan_translation_unit): Detect if the system-ness of the token we are about to emit is different from the one of the previously emitted token. If so, emit a line marker. Avoid emitting useless adjacent line markers. Avoid emitting line markers for tokens originating from the expansion of built-in macros. (scan_translation_unit_directives_only): Adjust. gcc/testsuite/ChangeLog: * gcc.dg/cpp/syshdr{4,5}.{c,h}: New test files. Signed-off-by: Dodji Seketeli Signed-off-by: Dodji Seketeli Added: trunk/gcc/testsuite/gcc.dg/cpp/syshdr4.c trunk/gcc/testsuite/gcc.dg/cpp/syshdr4.h trunk/gcc/testsuite/gcc.dg/cpp/syshdr5.c trunk/gcc/testsuite/gcc.dg/cpp/syshdr5.h Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-ppoutput.c trunk/gcc/testsuite/ChangeLog