diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -297,6 +297,10 @@ // Skip declarations delayed by late template parsing without a body. if (!Ctor->getBody()) return; + // Skip out-of-band explicitly defaulted special member functions + // (except the default constructor). + if (Ctor->isExplicitlyDefaulted() && !Ctor->isDefaultConstructor()) + return; checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor); checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), Ctor); } else if (const auto *Record = diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp @@ -501,3 +501,19 @@ void Bug33557() { NegativeImplicitInheritedCtor I(5); } + +struct NegativeDefaultedCtorOutOfDecl { + NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &); + int F; +}; + +NegativeDefaultedCtorOutOfDecl::NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &) = default; + +struct PositiveDefaultConstructorOutOfDecl { + PositiveDefaultConstructorOutOfDecl(); + int F; + // CHECK-FIXES: int F{}; +}; + +PositiveDefaultConstructorOutOfDecl::PositiveDefaultConstructorOutOfDecl() = default; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F