[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 9 14:48:15 PDT 2024


================
@@ -1472,3 +1472,25 @@ template<typename T> struct Outer {
   };
 };
 Outer<int>::Inner outerinner;
+
+void aggregate() {
----------------
higher-performance wrote:

> Could we add examples from @AaronBallman's [RFC comment](https://discourse.llvm.org/t/rfc-add-clang-attribute-to-ensure-that-fields-are-initialized-explicitly/80626/20)?

Done. Note that some errors are repeated. I wasn't able to figure out how to fix that without breaking the others, but it's related to `VerifyOnly` I think.

> empty struct, zero-width bitfields or all bitfields altogether

I'm not sure there's anything we need to special-case for those regardless? If e.g. a zero-width bitfield is annotated as requiring explicit initialization, then it should be initialized explicitly.

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


More information about the cfe-commits mailing list