Skip to content

Backend C: add parens to avoid warnings (potentially turned into errors) - #737

Open
paugier wants to merge 6 commits into
spylang:mainfrom
paugier:backend_c-parens-avoiding-warnings
Open

paugier wants to merge 6 commits into
spylang:mainfrom
paugier:backend_c-parens-avoiding-warnings

Conversation

@paugier

@paugier paugier commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

This comes from what I try to do with SIMD.

In a test in the CI SPY_WERROR=1 so warnings are turned into errors. Before these changes, expressions like n + 127 << 23 triggered a gcc warning.

I had to use AI to understand and produce the fix (but I tried to make it as clean as possible).

@paugier
paugier force-pushed the backend_c-parens-avoiding-warnings branch from 340c1cd to d38d559 Compare October 12, 2026 12:23
@paugier paugier changed the title Backend c parens avoiding warnings Backend C: add parens to avoid warnings (potentially turned into errors) Oct 12, 2026
@paugier
paugier marked this pull request as ready for review October 12, 2026 12:30

@antocuni antocuni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I just skimmed over the code and didn't look carefully.
But, can't we achieve the same effect by just tweaking the precendences in c_ast.BinOp._table?

@paugier

paugier commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

I don't think we can achieve the same result by just tweaking c_ast.BinOp._table.

However, we can use the data of this table to code the needed information in a much shorter way (but not very readable). I tried that in the last commit but I don't know what is better.

@paugier paugier mentioned this pull request Nov 4, 2026
5 of 17 tasks

This branch has not been deployed

No deployments
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.

2 participants