Repository navigation
Expand function macros that have arguments at the end #695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
2fb6739
ab690bb
ef9d14d
148b1c2
26ceaf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -989,6 +989,22 @@ static void define26() | |
| "f ( ) ( )", preprocess(code2)); | ||
| } | ||
|
|
||
| static void define27() | ||
| { | ||
| // an expansion result inside a macro argument that is a function-like macro | ||
| // name must be rescanned against the remaining argument tokens | ||
| const char code[] = "#define o1(a) a()\n" | ||
| "#define b(c, d) c##d\n" | ||
| "#define l(c, d) b(c, 1)\n" | ||
| "#define m(e, f)\n" | ||
| "#define g(h, i) m(h, )\n" | ||
| "#define j(h, i) g(h, )\n" | ||
| "#define k() l(j(, ), )\n" | ||
| "#define n(a) j(l(o, )(a), )\n" | ||
| "n(k)\n"; | ||
| ASSERT_EQUALS("", preprocess(code)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AI review The only new test is a large, fuzzer-style case whose expected output is
I checked all three against gcc, and they pass with this PR and fail on base. |
||
| } | ||
|
|
||
|
|
||
| static void define_invalid_1() | ||
| { | ||
|
|
@@ -4563,6 +4579,7 @@ static void runTests(int argc, char **argv, Input input) | |
| TEST_CASE(define24); | ||
| TEST_CASE(define25); | ||
| TEST_CASE(define26); | ||
| TEST_CASE(define27); | ||
| TEST_CASE(define_invalid_1); | ||
| TEST_CASE(define_invalid_2); | ||
| TEST_CASE(define_invalid_3); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that "so tok always advances" will be true now. If rescanMacro returns false directly should we return
tok->next?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it to return
tok->nextinstead relying on the callers to calltok->next.