[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 12:36:43 PDT 2024
================
@@ -551,3 +551,14 @@ struct full_of_empty empty_test_2(void) {
struct full_of_empty e;
return e; // no-warning
}
+
+struct with_explicit_field {
+ int x;
+ int y [[clang::requires_explicit_initialization]]; // expected-note 2{{'y' declared here}}
----------------
higher-performance wrote:
BTW, I realized that due to the way the syntax tree is constructed, the recursion into base classes was unnecessary after all -- so I just iterate over all the fields. See the updated test cases.
https://github.com/llvm/llvm-project/pull/102040
More information about the cfe-commits
mailing list