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)
Comment #1 by ibuclaw — 2022-02-26T21:34:13Z
To be clearer, this compiles, probably shouldn't.
---
#
line
12
void main()
{
}
---
Comment #2 by dlang-bot — 2022-02-27T10:25:09Z
@ibuclaw created dlang/dmd pull request #13727 "fix Issue 22825 - #line parsing doesn't follow the spec" fixing this issue:
- fix Issue 22825 - #line parsing doesn't follow the spec
https://github.com/dlang/dmd/pull/13727
Comment #3 by dlang-bot — 2022-02-28T11:07:45Z
@ibuclaw created dlang/dlang.org pull request #3234 "Issue 22825: First newline terminates special token sequences" mentioning this issue:
- Issue 22825: First newline terminates special token sequences
https://github.com/dlang/dlang.org/pull/3234
Comment #4 by dlang-bot — 2022-02-28T14:31:39Z
dlang/dlang.org pull request #3234 "Issue 22825: First newline terminates special token sequences" was merged into master:
- 92b9536d6307d3f48fd5634e3dc870ec63f8ed16 by Iain Buclaw:
Issue 22825: First newline terminates special token sequences
https://github.com/dlang/dlang.org/pull/3234
Comment #5 by bugzilla — 2022-03-02T21:47:15Z
Fix was merged.
Comment #6 by ibuclaw — 2022-03-03T18:23:42Z
Spec was merged, not the bug fix.
Comment #7 by dlang-bot — 2022-03-18T17:23:11Z
@ibuclaw updated dlang/dmd pull request #13728 "fix Issue 22812 - ImportC: C11 does not allow newlines between the start and end of a directive" fixing this issue:
- fix Issue 22825 - #line parsing doesn't follow the spec
https://github.com/dlang/dmd/pull/13728
Comment #8 by dlang-bot — 2022-03-22T13:10:06Z
dlang/dmd pull request #13728 "fix Issue 22812 - ImportC: C11 does not allow newlines between the start and end of a directive" was merged into master:
- dd708f0925e8daa70483422105201b5f02ee9829 by Iain Buclaw:
fix Issue 22825 - #line parsing doesn't follow the spec
https://github.com/dlang/dmd/pull/13728