[llvm] [llvm-rc] Add support for multiplication and division in expressions (PR #143373)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 12:56:46 PDT 2025


mstorsjo wrote:

> I was wondering if we should handle operator precedence correctly, like in `1 + 2 * 3`. With this PR, we currently evaluate addition first, resulting in 9. GNU windres seems to handle precedence properly and gives 7. MSVC rc.exe is odd, it appears to ignore multiplication and division entirely, just outputting 3.
> 
> I'm not sure what the best approach is here, what do you think?

Oh, that's indeed a good point, thanks for catching it!

That's weird if rc.exe does accept them but actually doesn't act on them. So perhaps they're not really a thing in canonical MS rc files - I guess that's why they're not implemented so far.

The case where I ran into this, https://github.com/DerellLicht/winwiz/blob/ed4134c44c22acc3746228eec34538d1e857dd6c/winwiz.rc#L250-L253, has parentheses so it should be unambiguous anyway (I think, or does it not honor them correctly either?), but if we do implement them I do think we should get the precedence right as well.

https://github.com/llvm/llvm-project/pull/143373


More information about the llvm-commits mailing list