Skip to content
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
8 changes: 7 additions & 1 deletion simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2019,7 +2019,13 @@ namespace simplecpp {

tok = tok->next;
if (tok == endToken2) {
output.push_back(new Token(*tok->previous));
if (tok) {
output.push_back(new Token(*tok->previous));
}
else {
output.push_back(new Token(*nameTokInst));
output.back()->setstr("\"\"");
}
break;
}
if (tok->op == '#') {
Expand Down
11 changes: 11 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,16 @@ static void define_va_opt_7()
toString(outputList));
}

static void define_va_opt_8()
{
const char code[] = "#define f(...) #__VA_OPT__(x)\n"
"const char* v1 = f();";

simplecpp::OutputList outputList;
ASSERT_EQUALS("\nconst char * v1 = \"\" ;", preprocess(code, &outputList));
ASSERT_EQUALS("", toString(outputList));
}

static void define_ifdef()
{
const char code[] = "#define A(X) X\n"
Expand Down Expand Up @@ -3350,6 +3360,7 @@ int main(int argc, char **argv)
TEST_CASE(define_va_opt_5);
TEST_CASE(define_va_opt_6);
TEST_CASE(define_va_opt_7);
TEST_CASE(define_va_opt_8);

TEST_CASE(pragma_backslash); // multiline pragma directive

Expand Down