================ @@ -616,3 +616,26 @@ class Foo { #undef INVALID_HANDLE_VALUE #undef RGB } + +namespace GH77684 { +struct S1 { +// CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'M' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] + S1() : M{} { M = 0; } +// CHECK-FIXES: S1() : M{0} + int M; +}; +struct S2 { +// CHECK-MESSAGES: :[[@LINE+1]]:17: warning: 'M' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] + S2() : M{2} { M = 1; } +// CHECK-FIXES: S2() : M{1} + int M; +}; +struct T { int a; int b; int c; }; +T v; +struct S3 { +// CHECK-MESSAGES: :[[@LINE+1]]:21: warning: 'M' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] + S3() : M{1,2,3} { M = v; } +// CHECK-FIXES: S3() : M{v} + T M; +}; +} ---------------- 5chmidti wrote:
Please add the empty body to the test. https://github.com/llvm/llvm-project/pull/81560 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits