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

This commit is contained in:
Walter Bright 2025-02-25 01:34:19 -08:00 committed by GitHub
parent 152815e9ec
commit beef42ebb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -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;
@ -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;
@ -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;

View file

@ -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;
}
---
*/
@ -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