Skip to content

Commit 024aeeb

Browse files
committed
non-arg
1 parent c2b2aa9 commit 024aeeb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

simplecpp.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,8 +2055,7 @@ namespace simplecpp {
20552055
const Token * tok2 = nullptr;
20562056
if (tok->next->op == '(')
20572057
tok2 = appendTokens(&tokens, loc, tok->next, macros, expandedmacros, parametertokens);
2058-
else if (tok->next->name && tok->next->next && tok->next->next->op != '(') {
2059-
expandToken(&tokens, loc, tok->next, macros, expandedmacros2, parametertokens);
2058+
else if (expandArg(&tokens, tok->next, loc, macros, expandedmacros, parametertokens)) {
20602059
if (tokens.cfront()->next && tokens.cfront()->next->op == '(')
20612060
tok2 = tok->next;
20622061
}

test.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,16 @@ static void define_define_20() // #384 arg contains comma
823823

824824
static void define_define_21() // #397 DEBRACKET macro
825825
{
826-
const char code[] = "#define A(val) B val\n"
827-
"#define B(val) val\n"
828-
"A((2))\n";
829-
ASSERT_EQUALS("\n\n2", preprocess(code));
826+
const char code1[] = "#define A(val) B val\n"
827+
"#define B(val) val\n"
828+
"A((2))\n";
829+
ASSERT_EQUALS("\n\n2", preprocess(code1));
830+
831+
const char code2[] = "#define x (2)\n"
832+
"#define A B x\n"
833+
"#define B(val) val\n"
834+
"A\n";
835+
ASSERT_EQUALS("\n\n\nB ( 2 )", preprocess(code2));
830836
}
831837

832838
static void define_va_args_1()

0 commit comments

Comments
 (0)