https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm made very
clear that it is an UB having type definitions with in offsetof. After
this patch clang will reject any type definitions in __builtin_offsetof.
Fixes https://github.com/llvm/llvm-project/issues/57065
local/offsetof.c:10:38: error: 'struct S' cannot be defined in '__builtin_offsetof'
return __builtin_offsetof(struct S{ int a, b;}, a);
^
We might want this change, we might not -- can you test the diagnostic behavior when using #include <stddef.h>? Does it print __builtin_offsetof in the following example?
#include <stddef.h> int main() { return offsetof(struct S { int a; }, a); }when executed with clang -fsyntax-only -ffreestanding -std=c2x test.c
If it prints the builtin name, I think we'll want to look at the builtin token to see if it was expanded from a macro named offsetof to improve the diagnostic quality.