diff --git a/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index eabadd8..9ba8bd9 100644 --- a/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -31,6 +31,8 @@ void fieldsRequiringInit(const RecordDecl::field_range &Fields, ASTContext &Context, SmallPtrSetImpl &FieldsToInit) { for (const FieldDecl *F : Fields) { + if (F->hasInClassInitializer()) + continue; QualType Type = F->getType(); if (!F->hasInClassInitializer() && type_traits::isTriviallyDefaultConstructible(Type, Context)) diff --git a/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp b/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp index b95f158..4cda3a4 100644 --- a/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp +++ b/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp @@ -85,6 +85,14 @@ struct NegativeInitializedInBody { int I; }; +struct A {}; +template class AA; +template class NegativeTemplateConstructor { + NegativeTemplateConstructor(const AA &, A) {} + bool Bool{false}; + // CHECK-FIXES: bool Bool{false}; +}; + #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \ struct UninitializedField##FIELD { \ UninitializedField##FIELD() {} \