public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "nicholas.ormrod at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/60723] Line directives with incorrect system header flag Date: Tue, 01 Apr 2014 01:37:00 -0000 [thread overview] Message-ID: <bug-60723-4-fvW4bWxIj9@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-60723-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60723 --- Comment #1 from Nicholas <nicholas.ormrod at hotmail dot com> --- The preprocessor emits line directives with the system-header flag when using complicated macros. This causes certain warnings, like -Wswitch and -Wreorder, to be suppressed. This report includes a patch as well as a detailed description. == Reproduction Steps == Preprocessing must be done in a separate phase. There must be a function-like macro which: (1) Is called with a newline inside of its arguments list (2) Is defined in a system header (3) Expands to contain a builtin macro followed by a non-builtin token A minimal reproduction is attached. Compiling 'src.cpp' produces a div-by-zero warning when compiled by "g++ -isystem. src.cpp". No warning is emitted when preprocessing is split, such as with "g++ -isystem. -no-integrated-cpp src.cpp". == Cause == The preprocessed output of 'src.cpp' shows that a line directive is being inserted after the __FILE__ macro, and that that directive is flagging 'src.cpp' as a system file (using the flag '3'). In a function-like macro expansion, regular tokens are line-marked as being expanded at the opening parenthesis, while builtins are line-marked as being expanded at the closing parenthesis (both of these choices are reasonable, though the inconsistency is probably a design flaw). When a non-builtin follows a builtin in a multiline macro call, the line numbers of the tokens are inconsistent, forcing a line directive to be inserted. == Details == This bug was occurring in our code base. We use ccache (which preprocesses independently of main compilation) and gflags (which has sufficiently complicated macros). Testing was done on 4.9. Git bisect blames 611f1003dbf4ebb341c2eda0fcc0e058c421eb6b (4.8.0 20120430), authored by dodji on Mon Apr 30 11:43:43 2012 +0000. However, that diff does not seem to be the root cause. gcc -v Using built-in specs. COLLECT_GCC=./igpp COLLECT_LTO_WRAPPER=/data/users/njormrod/src/gcc/_builds/39706bc97269366073d2eb4cf3ecf7872513627d/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../../src/configure --prefix=/data/users/njormrod/src/gcc/_builds/39706bc97269366073d2eb4cf3ecf7872513627d --with-gmp=[local gmp-5.0.1] --with-mpfr=[local mpfr-3.0.0] --with-mpc=[local mpc-0.8.2] --disable-multilib --enable-languages=c,c++ --disable-libgcj --disable-bootstrap --disable-static Thread model: posix gcc version 4.9.0 20140331 (experimental) (GCC)
next prev parent reply other threads:[~2014-04-01 1:37 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 ` nicholas.ormrod at hotmail dot com [this message] 2014-04-01 1:38 ` [Bug preprocessor/60723] " 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
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-fvW4bWxIj9@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: linkBe 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).