Skip to content

Commit 6a6865d

Browse files
authored
Fixup #397 (Debracket macro not expanded) (#399)
1 parent 4bb6eba commit 6a6865d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: simplecpp.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2056,6 +2056,7 @@ namespace simplecpp {
20562056
if (tok->next->op == '(')
20572057
tok2 = appendTokens(&tokens, loc, tok->next, macros, expandedmacros, parametertokens);
20582058
else if (expandArg(&tokens, tok->next, loc, macros, expandedmacros, parametertokens)) {
2059+
tokens.front()->location = loc;
20592060
if (tokens.cfront()->next && tokens.cfront()->next->op == '(')
20602061
tok2 = tok->next;
20612062
}

Diff for: test.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,12 @@ static void define_define_21() // #397 DEBRACKET macro
833833
"#define B(val) val\n"
834834
"A\n";
835835
ASSERT_EQUALS("\n\n\nB ( 2 )", preprocess(code2));
836+
837+
const char code3[] = "#define __GET_ARG2_DEBRACKET(ignore_this, val, ...) __DEBRACKET val\n"
838+
"#define __DEBRACKET(...) __VA_ARGS__\n"
839+
"#5 \"a.c\"\n"
840+
"__GET_ARG2_DEBRACKET(432 (33), (B))\n";
841+
ASSERT_EQUALS("\n#line 5 \"a.c\"\nB", preprocess(code3));
836842
}
837843

838844
static void define_va_args_1()

0 commit comments

Comments
 (0)