Skip to content
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

Fix sizeof precedence #168

Merged
merged 3 commits into from
Oct 4, 2023
Merged

Conversation

philipturnbull
Copy link
Contributor

Increase the precedence of sizeof. Previously, an expression like:

len = sizeof(int) + 1;

would be parsed as:

len = sizeof ((int) + 1);

i.e the size of +1 cast to an int.


Also:

  • I also added tests to offsetof(...) to check that it behaves correctly.
  • Wrong precedences for sizeof and conditional operator #51 mentions problems with the precedence of the ternary operator, but that appears to have been fixed since the issue was opened. I added a couple of tests to prevent regressions in the future.

Fixes #51

@amaanq
Copy link
Member

amaanq commented Oct 4, 2023

Can you regenerate w/ the Rust cli crate on master?

@aryx aryx requested a review from amaanq October 4, 2023 21:02
@amaanq amaanq merged commit f1075f2 into tree-sitter:master Oct 4, 2023
4 checks passed
@philipturnbull philipturnbull deleted the sizeof-precedence branch October 4, 2023 23:40
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.

Wrong precedences for sizeof and conditional operator
2 participants