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 {
2094
2094
2095
2095
tok = tok->next ;
2096
2096
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
+ }
2098
2104
break ;
2099
2105
}
2100
2106
if (tok->op == ' #' ) {
Original file line number Diff line number Diff line change @@ -1041,6 +1041,16 @@ static void define_va_opt_7()
1041
1041
toString (outputList));
1042
1042
}
1043
1043
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
+
1044
1054
static void define_ifdef ()
1045
1055
{
1046
1056
const char code[] = " #define A(X) X\n "
@@ -3398,6 +3408,7 @@ int main(int argc, char **argv)
3398
3408
TEST_CASE (define_va_opt_5);
3399
3409
TEST_CASE (define_va_opt_6);
3400
3410
TEST_CASE (define_va_opt_7);
3411
+ TEST_CASE (define_va_opt_8);
3401
3412
3402
3413
TEST_CASE (pragma_backslash); // multiline pragma directive
3403
3414
You can’t perform that action at this time.
0 commit comments