[Issue 22825] New: #line parsing doesn't follow the spec

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 26 10:11:33 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22825

          Issue ID: 22825
           Summary: #line parsing doesn't follow the spec
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ibuclaw at gdcproject.org

Grammar is:

---
SpecialTokenSequence:
    # line IntegerLiteral Filespec(opt) EndOfLine
    # line __LINE__ Filespec(opt) EndOfLine
---

Because newlines (EndOfLine) is part of the grammar, then any other newlines
found between `#` and `EndOfLine` should not be ignored when parsing them.

This does not apply to multi-line comments, and other such markers that are
consumed and ignored by the lexer.

So while this should be accepted as valid code
---
#line /*
         multi-line comment
*/ 42
int var;
---

This should not compile, but currently does.
---
#line /*
         multi-line comment
*/ 
42
int var;
---

(There are similarities in this to issue 22812 for importC)

--


More information about the Digitalmars-d-bugs mailing list