File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff 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 == ' #' ) {
Original file line number Diff line number Diff 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 (" \n const char * v1 = \"\" ;" , preprocess (code, &outputList));
1051+ ASSERT_EQUALS (" " , toString (outputList));
1052+ }
1053+
10441054static void define_ifdef ()
10451055{
10461056 const char code[] = " #define A(X) X\n "
@@ -3431,6 +3441,7 @@ int main(int argc, char **argv)
34313441 TEST_CASE (define_va_opt_5);
34323442 TEST_CASE (define_va_opt_6);
34333443 TEST_CASE (define_va_opt_7);
3444+ TEST_CASE (define_va_opt_8);
34343445
34353446 TEST_CASE (pragma_backslash); // multiline pragma directive
34363447
You can’t perform that action at this time.
0 commit comments