[clang] Rewrite offsetof with __builtin_offsetof with -fms-kernel (PR #193804)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu May 7 05:57:46 PDT 2026
AaronBallman wrote:
> Maybe MSVC has logic similar to `-Wgnu-folding-constant`? clang also folds the array bounds in your example.
That's what I think might be happening, but I think more comprehensive research is needed to figure out what is and isn't supported by cl to help decide how we want to proceed,
To me, there's a prerequisite question we should answer first: should functionality be gated on `-fms-kernel` in Clang if it doesn't require `/kernel` in cl? (Also keep in mind that we have clang-cl which mimics cl command line options; we currently have this one under the "unsupported" list currently but I imagine we'll want to hook that option up to `-fms-kernel` at some point: https://github.com/llvm/llvm-project/blob/ce16067aab54ae04f98e6ef5edd1bd7a68d33d90/clang/include/clang/Options/Options.td#L9534)
That said, it's also not clear to me if this is `-fms-compatibility` or `-fms-extensions` -- the lack of documentation on MSDN for the extension, plus it working without `/kernel` is why I think `-fms-compatibility` is the correct approach. But if this is an official extension of some kind, I could see an argument for `-fms-extensions` too.
https://github.com/llvm/llvm-project/pull/193804
More information about the cfe-commits
mailing list