public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ktietz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/8270] [4.8/4.9/5 Regression] back-slash white space newline with comments, no warning Date: Thu, 19 Mar 2015 14:21:00 -0000 [thread overview] Message-ID: <bug-8270-4-uBaX7Ue4Ys@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-8270-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8270 Kai Tietz <ktietz at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ktietz at gcc dot gnu.org --- Comment #55 from Kai Tietz <ktietz at gcc dot gnu.org> --- Well, by looking into the standard ISO/IEC 9899:TC3 I found the following statement: 5.1.12 Translation phase "2. Each instance of a backslash character (\) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place." For ISO/IEC 14882:2003 we see at topic "2 Lexical Convention" "2 Each instance of a new-line character and an immediately preceding backslash character is deleted, splicing physical source lines to form logical source lines. If, as a result, a character sequence that matches the syntax of a universal-character-name is produced, the behavior is undefined. If a source file that is not empty does not end in a new-line character, or ends in a new-line character immediately preceded by a backslash character, the behavior is undefined." So the handling of backslash whitespace newline is clearly a gnu-extension and not part of the standard. I suggest something like this patch for fixing standard-requirement. Additionally we could check here for cpp_option lang being gnu-style for allowing 'backslash,whitespaces,newling' too. Index: lex.c =================================================================== --- lex.c (Revision 221514) +++ lex.c (Arbeitskopie) @@ -896,6 +896,11 @@ _cpp_clean_line (cpp_reader *pfile) p--; if (p - 1 != pbackslash) goto done; + if (p != d) + { + ++p; + goto done; + } /* Have an escaped newline; process it and proceed to the slow path. */ @@ -917,13 +922,19 @@ _cpp_clean_line (cpp_reader *pfile) if (s == buffer->rlimit) break; - /* Escaped? */ + /* Escaped? + But make sure it isn't a backslash followed by a + whitespace. */ p = d; while (p != buffer->next_line && is_nvspace (p[-1])) p--; if (p == buffer->next_line || p[-1] != '\\') break; - + if (p != d) + { + ++p; + break; + } add_line_note (buffer, p - 1, p != d ? ' ': '\\'); d = p - 2; buffer->next_line = p - 1;
next prev parent reply other threads:[~2015-03-19 13:23 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-8270-4@http.gcc.gnu.org/bugzilla/> 2011-06-27 12:16 ` [Bug preprocessor/8270] [4.3/4.4/4.5/4.6/4.7 " rguenth at gcc dot gnu.org 2012-03-13 12:47 ` [Bug preprocessor/8270] [4.5/4.6/4.7/4.8 " jakub at gcc dot gnu.org 2012-07-02 12:40 ` [Bug preprocessor/8270] [4.6/4.7/4.8 " rguenth at gcc dot gnu.org 2013-04-12 15:15 ` [Bug preprocessor/8270] [4.7/4.8/4.9 " jakub at gcc dot gnu.org 2013-12-11 12:41 ` GoWhoopee at yahoo dot com 2013-12-11 18:33 ` pinskia at gcc dot gnu.org 2013-12-12 8:24 ` GoWhoopee at yahoo dot com 2013-12-12 15:02 ` mikpelinux at gmail dot com 2013-12-13 8:15 ` GoWhoopee at yahoo dot com 2013-12-13 10:48 ` GoWhoopee at yahoo dot com 2014-06-12 13:41 ` [Bug preprocessor/8270] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org 2014-12-19 13:23 ` [Bug preprocessor/8270] [4.8/4.9/5 " jakub at gcc dot gnu.org 2015-03-19 14:21 ` ktietz at gcc dot gnu.org [this message] 2015-03-21 15:25 ` doug at cs dot dartmouth.edu 2015-03-23 9:49 ` ktietz at gcc dot gnu.org 2015-06-23 8:12 ` [Bug preprocessor/8270] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org 2015-06-26 19:51 ` [Bug preprocessor/8270] [4.9/5/6 " jakub at gcc dot gnu.org 2015-06-26 20:25 ` jakub at gcc dot gnu.org 2021-05-14 9:45 ` [Bug preprocessor/8270] [9/10/11/12 " jakub at gcc dot gnu.org 2021-06-01 8:03 ` rguenth at gcc dot gnu.org 2022-05-27 9:33 ` [Bug preprocessor/8270] [10/11/12/13 " rguenth at gcc dot gnu.org 2022-06-28 10:28 ` jakub at gcc dot gnu.org 2023-07-07 10:28 ` [Bug preprocessor/8270] [11/12/13/14 " rguenth at gcc dot gnu.org 2024-03-10 12:09 ` verodeving at gmail dot com
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-8270-4-uBaX7Ue4Ys@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).