public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/60723] Line directives with incorrect system header flag
Date: Wed, 12 Oct 2022 22:16:25 +0000	[thread overview]
Message-ID: <bug-60723-4-s3405m00TY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60723-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60723

--- Comment #32 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Lewis Hyatt <lhyatt@gcc.gnu.org>:

https://gcc.gnu.org/g:ddb7f0a0cac48762ba6408d69538f8115c4a2739

commit r13-3264-gddb7f0a0cac48762ba6408d69538f8115c4a2739
Author: Lewis Hyatt <lhyatt@gmail.com>
Date:   Thu Oct 6 18:05:02 2022 -0400

    preprocessor: Fix tracking of system header state [PR60014,PR60723]

    The token_streamer class (which implements gcc mode -E and
    -save-temps/-no-integrated-cpp) needs to keep track whether the last tokens
    output were in a system header, so that it can generate line marker
    annotations as necessary for a downstream consumer to reconstruct the
    state. The logic for tracking it, which was added by r5-1863 to resolve
    PR60723, has some edge case issues as revealed by the three new test
    cases. The first, coming from the original PR60014, was incidentally fixed
by
    r9-1926 for unrelated reasons. The other two were still failing on master
    prior to this commit. Such code paths were not realizable prior to
r13-1544,
    which made it possible for the token streamer to see CPP_PRAGMA tokens in
more
    contexts.

    The two main issues being corrected here are:

    1) print.prev_was_system_token needs to indicate whether the previous token
    output was in a system location. However, it was not being set on every
token,
    only on those that triggered the main code path; specifically it was not
    triggered on a CPP_PRAGMA token. Testcase 2 covers this case.

    2) The token_streamer uses a variable "line_marker_emitted" to remember
    whether a line marker has been emitted while processing a given token, so
that
    it wouldn't be done more than once in case multiple conditions requiring a
    line marker are true. There was no reason for this to be a member variable
    that retains its value from token to token, since it is just needed for
    tracking the state locally while processing a single given token. The fact
    that it could retain its value for a subsequent token is rather difficult
to
    observe, but testcase 3 demonstrates incorrect behavior resulting from
    that. Moving this to a local variable also simplifies understanding the
    control flow going forward.

    gcc/c-family/ChangeLog:

            PR preprocessor/60014
            PR preprocessor/60723
            * c-ppoutput.cc (class token_streamer): Remove member
            line_marker_emitted to...
            (token_streamer::stream): ...a local variable here. Set
            print.prev_was_system_token on all code paths.

    gcc/testsuite/ChangeLog:

            PR preprocessor/60014
            PR preprocessor/60723
            * gcc.dg/cpp/pr60014-1.c: New test.
            * gcc.dg/cpp/pr60014-1.h: New test.
            * gcc.dg/cpp/pr60014-2.c: New test.
            * gcc.dg/cpp/pr60014-2.h: New test.
            * gcc.dg/cpp/pr60014-3.c: New test.
            * gcc.dg/cpp/pr60014-3.h: New test.

      parent reply	other threads:[~2022-10-12 22:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01  1:37 [Bug preprocessor/60723] New: " nicholas.ormrod at hotmail dot com
2014-04-01  1:37 ` [Bug preprocessor/60723] " nicholas.ormrod at hotmail dot com
2014-04-01  1:38 ` nicholas.ormrod at hotmail dot com
2014-04-01  1:39 ` nicholas.ormrod at hotmail dot com
2014-04-01  9:51 ` manu at gcc dot gnu.org
2014-04-01 15:30 ` nicholas.ormrod at hotmail dot com
2014-06-10  6:21 ` nicholas.ormrod at hotmail dot com
2014-06-10 13:18 ` matt at godbolt dot org
2014-06-15 22:31 ` nicholas.ormrod at hotmail dot com
2014-06-25 15:32 ` dodji at gcc dot gnu.org
2014-07-01  9:18 ` dodji at gcc dot gnu.org
2014-07-01 14:13 ` christophe.lyon at st dot com
2014-07-01 14:16 ` christophe.lyon at st dot com
2014-07-02 13:43 ` dodji at gcc dot gnu.org
2014-07-02 13:44 ` dodji at gcc dot gnu.org
2014-07-03 13:48 ` christophe.lyon at st dot com
2014-07-16  8:58 ` dodji at gcc dot gnu.org
2014-07-16 10:34 ` dodji at gcc dot gnu.org
2014-07-16 13:38 ` dodji at gcc dot gnu.org
2014-07-17  3:36 ` nicholas.ormrod at hotmail dot com
2014-07-22  9:55 ` ktkachov at gcc dot gnu.org
2014-07-24  8:22 ` ktkachov at gcc dot gnu.org
2015-02-05 10:07 ` jakub at gcc dot gnu.org
2021-03-26 23:31 ` egallager at gcc dot gnu.org
2022-10-12 22:16 ` cvs-commit at gcc dot gnu.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60723-4-s3405m00TY@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).