-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for literal zero in FnPtrNull rewriter pass
#438
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: main
Are you sure you want to change the base?
Changes from 4 commits
c538d8f
8c7e95f
8af390e
5c60763
ce03676
dfa579a
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 |
|---|---|---|
|
|
@@ -27,7 +27,9 @@ Test(rewrite_fn_ptr_eq, main) { | |
| int res; | ||
| int *y = &res; | ||
| void *x = NULL; | ||
| // REWRITER: bin_op fn = IA2_FN(add); | ||
| bin_op fn = add; | ||
| // REWRITER: bin_op fn2 = { NULL }; | ||
| bin_op fn2 = NULL; | ||
|
|
||
| // Check that pointers for types other than functions are not rewritten | ||
|
|
@@ -78,4 +80,31 @@ Test(rewrite_fn_ptr_eq, main) { | |
| if (y || !fn) { } | ||
| // REWRITER: if (x && IA2_ADDR(fn) && y) { } | ||
| if (x && fn && y) { } | ||
|
|
||
| // REWRITER: fn = (typeof(fn)) { NULL }; | ||
| fn = NULL; | ||
|
Comment on lines
+84
to
+85
Contributor
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. I don't think this case is handled correctly if using a define other than strm->zalloc = Z_NULL;gets rewritten to strm->zfree = (typeof(strm->zfree)) { 0 };I'm not sure if that's something we can or care to fix, since it doesn't really have a functional difference.
Contributor
Author
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. The output is totatlly broken rn but that's a good catch about custom |
||
|
|
||
| // the following tests don't use NULL so the rewriter output shouldn't rely on it either | ||
| #undef NULL | ||
| // REWRITER: bin_op fn3 = { 0 }; | ||
| bin_op fn3 = 0; | ||
|
|
||
| // REWRITER: fn = (typeof(fn)) { 0 }; | ||
| fn = 0; | ||
|
|
||
| // check that literal zeroes aren't rewritten if not cast to function pointers | ||
| // REWRITER: res = 0; | ||
| res = 0; | ||
|
|
||
| // REWRITER: if (IA2_ADDR(fn) == 0) { } | ||
| if (fn == 0) { } | ||
|
|
||
| // REWRITER: if (IA2_ADDR(mod.fn) == 0) { } | ||
| if (mod.fn == 0) { } | ||
|
|
||
| // REWRITER: if (IA2_ADDR(fn) == 0) { } | ||
| if (fn == (typeof(fn))0) { } | ||
|
|
||
| // REWRITER: if (IA2_ADDR(mod.fn) == 0) { } | ||
| if (mod.fn == (typeof(fn))0) { } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.