Allow '//'-style comments in #defines.
This commit is contained in:
parent
0b2de0de64
commit
0b1827a5b2
2 changed files with 16 additions and 3 deletions
|
@ -3821,8 +3821,20 @@ class Compiler : public ErrorSink {
|
|||
inp();
|
||||
}
|
||||
String value;
|
||||
bool appendToValue = true;
|
||||
while (ch != '\n' && ch != EOF) {
|
||||
value.append(ch);
|
||||
// Check for '//' comments.
|
||||
if (appendToValue && ch == '/') {
|
||||
inp();
|
||||
if (ch == '/') {
|
||||
appendToValue = false;
|
||||
} else {
|
||||
value.append('/');
|
||||
}
|
||||
}
|
||||
if (appendToValue && ch != EOF) {
|
||||
value.append(ch);
|
||||
}
|
||||
inp();
|
||||
}
|
||||
char* pDefn = (char*)mGlobalArena.alloc(value.len() + 1);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// Simple tests of the C preprocessor
|
||||
|
||||
#define A (1 + 2)
|
||||
#define A (4 / 2)
|
||||
#define B 1 // This is a comment. With a / in it.
|
||||
|
||||
int main() {
|
||||
return A;
|
||||
return A + B;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue