[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 10:29:10 PDT 2024
================
@@ -1472,3 +1472,56 @@ template<typename T> struct Outer {
};
};
Outer<int>::Inner outerinner;
+
+void aggregate() {
+ struct NonAgg {
+ NonAgg() { }
+ [[clang::requires_explicit_initialization]] int f; // expected-warning {{'requires_explicit_initialization' attribute is ignored in non-aggregate type 'NonAgg'}}
+ };
+ NonAgg nonagg; // no-warning
+ (void)nonagg;
+
+ struct S {
+ [[clang::requires_explicit_initialization]] int x; // expected-note 7{{'x' declared here}}
----------------
erichkeane wrote:
And here, throughout file.
https://github.com/llvm/llvm-project/pull/102040
More information about the cfe-commits
mailing list