[clang] Add Clang attribute to ensure that fields are initialized explicitly (PR #102040)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 21 10:20:12 PST 2024
================
@@ -551,3 +551,32 @@ 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]]; // #FIELD_Y
+};
+
+struct with_explicit_array {
+ [[clang::requires_explicit_initialization]] int arr[2]; // #FIELD_ARR
+};
+
+struct with_explicit_flex_array {
+ [[clang::requires_explicit_initialization]] int flex_arr[]; // #FIELD_FLEX_ARR
----------------
AaronBallman wrote:
This class should have another field that isn't a FAM, otherwise you get additional diagnostics.
https://github.com/llvm/llvm-project/pull/102040
More information about the cfe-commits
mailing list