Skip to content

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

Merged
merged 6 commits into from
Jan 10, 2020
Merged

Fix translation of signed array indices #4113

merged 6 commits into from
Jan 10, 2020

Conversation

travisstaloch
Copy link
Contributor

@travisstaloch
Copy link
Contributor Author

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.

@travisstaloch
Copy link
Contributor Author

😊 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. 🐑

@@ -363,7 +363,7 @@ fn prepopulateGlobalNameTable(ast_unit: *ZigClangASTUnit, c: *Context) !void {
}
}

fn declVisitorNamesOnlyC(context: ?*c_void, decl: *const ZigClangDecl) callconv(.C) bool {
Copy link
Contributor Author

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.

@travisstaloch
Copy link
Contributor Author

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.

Copy link
Member

@andrewrk andrewrk left a 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.


cases.add("cast signed array index to unsigned",
\\#include <stdlib.h>
\\#define _NO_CRT_STDIO_INLINE 1
Copy link
Member

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.

Copy link
Contributor Author

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 1s

@andrewrk
Copy link
Member

andrewrk commented Jan 9, 2020

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.

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.


cases.add("cast signed array index to unsigned",
\\#include <stdlib.h>
\\void main(int argc, char **argv) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. done.

@travisstaloch
Copy link
Contributor Author

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.

@andrewrk
Copy link
Member

That's done in 4e4ba6c; if this PR is rebased against that commit or later then it will be so

@andrewrk andrewrk merged commit 3f98756 into ziglang:master Jan 10, 2020
@andrewrk
Copy link
Member

Nice work!

@travisstaloch
Copy link
Contributor Author

Thanks 👍 Thanks for being patient with my git foibles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

translate-c doesn't cast signed array index
2 participants