-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix translation of signed array indices #4113
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
Conversation
travisstaloch
commented
Jan 8, 2020
- Closes translate-c doesn't cast signed array index #4075
It is likely easier on everyone to get rid of that bad rebase/merge attempt from #4079 now. Please bear with me as I sometimes struggle with git. I'm a little rusty and currently focusing on making this a better experience. I didn't mean to close the last PR, but deleting those commits triggered it. Hope this is better. |
😊 Annnd I'm hoping the third time is a charm. Once again didn't mean to close another pull request. Now I know not to force push on a PR. 🐑 |
src-self-hosted/translate_c.zig
Outdated
@@ -363,7 +363,7 @@ fn prepopulateGlobalNameTable(ast_unit: *ZigClangASTUnit, c: *Context) !void { | |||
} | |||
} | |||
|
|||
fn declVisitorNamesOnlyC(context: ?*c_void, decl: *const ZigClangDecl) callconv(.C) bool { |
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 thought this might be causing CI test failures on windows/macos. This doesn't seem to be the case.
These windows/macos CI failures seem to be on test-run-translated-c. I think they're a result of using assert.h as observed in #4101. |
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.
The test failure is that the translated code is running and exiting with nonzero exit code. That's my fault that it's not showing the test case name, I'll fix that.
test/run_translated_c.zig
Outdated
|
||
cases.add("cast signed array index to unsigned", | ||
\\#include <stdlib.h> | ||
\\#define _NO_CRT_STDIO_INLINE 1 |
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.
You don't need this workaround unless using stdio.h and printf.
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.
Removed #define _NO_CRT_STDIO_INLINE 1
s
don't worry about it, no big deal. I'm not sure what problem you ran into, but you can force push a branch that is a pull request, it should work fine. |
test/run_translated_c.zig
Outdated
|
||
cases.add("cast signed array index to unsigned", | ||
\\#include <stdlib.h> | ||
\\void main(int argc, char **argv) { |
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 believe using void main
rather than int main
makes your exit code undefined. Better would be to use c_int and return 0 like the other tests do.
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.
good catch. done.
Not sure if you already did, but it would be nice to print the failing test name in test/translate_c.zig as well as test/run_translated_c.zig. |
That's done in 4e4ba6c; if this PR is rebased against that commit or later then it will be so |
Nice work! |
Thanks 👍 Thanks for being patient with my git foibles. |