Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #20912 lexing problem with #define // comments #20914

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ class Lexer
case 0:
case 0x1A:
error(t.loc, "unterminated /* */ comment");
p = end;
//p = end;
t.loc = loc();
t.value = TOK.endOfFile;
return;
Expand Down Expand Up @@ -927,7 +927,7 @@ class Lexer
getDocComment(t, lastLine == startLoc.linnum, startLoc.linnum - lastDocLine > 1);
lastDocLine = linnum;
}
p = end;
//p = end;
t.loc = loc();
t.value = TOK.endOfFile;
return;
Expand Down Expand Up @@ -1003,7 +1003,7 @@ class Lexer
case 0:
case 0x1A:
error(t.loc, "unterminated /+ +/ comment");
p = end;
//p = end;
t.loc = loc();
t.value = TOK.endOfFile;
return;
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/compilable/ctod.i
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ extern (C)
/+enum int __TIMESTAMP__ = 1+/;
/+enum int __EOF__ = 1+/;
/+enum int __VENDOR__ = 1+/;
enum int DEF = 123;
enum int SQL_DRIVER_STMT_ATTR_BASE = 16384;
enum int ABC = 64;
}
---
*/
Expand Down Expand Up @@ -124,3 +127,7 @@ struct Test
};

int arr[(ULONG) 3];

#define DEF 123
#define SQL_DRIVER_STMT_ATTR_BASE 0x00004000 // 32-bit
#define ABC 64
Loading