[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 07:21:37 PDT 2023


================
@@ -50,9 +50,9 @@ struct Derived2 : public Base1, public Base2 {
   int z; 
 };
 
-int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1];
-int derived2[__builtin_offsetof(Derived2, y)  == 4? 1 : -1];
-int derived3[__builtin_offsetof(Derived2, z)  == 8? 1 : -1];
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1]; // expected-warning{{offset of on non-POD type 'Derived2'}}
----------------
AaronBallman wrote:

This also seems like an improvement in diagnostic behavior.

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


More information about the cfe-commits mailing list