[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 11:03:28 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 {{attribute is ignored}}
+ };
+ NonAgg nonagg;
+ (void)nonagg;
+
+ struct S {
+ [[clang::requires_explicit_initialization]] int x; // expected-note {{declared}} // expected-note {{declared}} // expected-note {{declared}} // expected-note {{declared}}
----------------
higher-performance wrote:
Done.
https://github.com/llvm/llvm-project/pull/102040
More information about the cfe-commits
mailing list