Bug 22814 – ImportC: C11 lexer deletes escaped new lines during translation

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-22T18:51:04Z
Last change time
2022-02-28T07:29:33Z
Keywords
ImportC, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw

Comments

Comment #0 by ibuclaw — 2022-02-22T18:51:04Z
Following on from issue 22812, while new lines can't be ignored, they can however be escaped. From C11 5.1.1.2-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. --- So whilst issue 22812 is an error, this should be accepted as valid: --- # \ pragma \ pack \ ( \ 2 \ ) struct S { int i; short j; double k; }; # \ pragma \ pack \ ( \ ) ---
Comment #1 by bugzilla — 2022-02-28T07:29:33Z
Backslash line splicing is done by the preprocessor, not the C compiler. (Try it, run the example code through cpp.) So the ImportC lexer should never see the \, and this is not a bug in ImportC.