Skip to content

Commit fc9ccc5

Browse files
chrchr-githubfirewave
authored andcommitted
Update test.cpp [skip ci]
Update simplecpp.cpp
1 parent dfd2f2c commit fc9ccc5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

simplecpp.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,13 @@ namespace simplecpp {
20942094

20952095
tok = tok->next;
20962096
if (tok == endToken2) {
2097-
output.push_back(new Token(*tok->previous));
2097+
if (tok) {
2098+
output.push_back(new Token(*tok->previous));
2099+
}
2100+
else {
2101+
output.push_back(new Token(*nameTokInst));
2102+
output.back()->setstr("\"\"");
2103+
}
20982104
break;
20992105
}
21002106
if (tok->op == '#') {

test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,16 @@ static void define_va_opt_7()
10411041
toString(outputList));
10421042
}
10431043

1044+
static void define_va_opt_8()
1045+
{
1046+
const char code[] = "#define f(...) #__VA_OPT__(x)\n"
1047+
"const char* v1 = f();";
1048+
1049+
simplecpp::OutputList outputList;
1050+
ASSERT_EQUALS("\nconst char * v1 = \"\" ;", preprocess(code, &outputList));
1051+
ASSERT_EQUALS("", toString(outputList));
1052+
}
1053+
10441054
static void define_ifdef()
10451055
{
10461056
const char code[] = "#define A(X) X\n"
@@ -3398,6 +3408,7 @@ int main(int argc, char **argv)
33983408
TEST_CASE(define_va_opt_5);
33993409
TEST_CASE(define_va_opt_6);
34003410
TEST_CASE(define_va_opt_7);
3411+
TEST_CASE(define_va_opt_8);
34013412

34023413
TEST_CASE(pragma_backslash); // multiline pragma directive
34033414

0 commit comments

Comments
 (0)