diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -15254,9 +15254,15 @@ } // C++ [module.import/6] external definitions are not permitted in header - // units. + // units. Deleted and Defaulted functions are implicitly inline (but the + // inline state is not set at this point, so check the BodyKind explicitly). + // FIXME: Consider an alternate location for the test where the inlined() + // state is complete. if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() && - FD->getFormalLinkage() == Linkage::ExternalLinkage && !FD->isInlined()) { + FD->getFormalLinkage() == Linkage::ExternalLinkage && + !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete && + BodyKind != FnBodyKind::Default && !FD->isInlined()) { + assert(FD->isThisDeclarationADefinition()); Diag(FD->getLocation(), diag::err_extern_def_in_header_unit); FD->setInvalidDecl(); } diff --git a/clang/test/CXX/module/module.import/p6.cpp b/clang/test/CXX/module/module.import/p6.cpp --- a/clang/test/CXX/module/module.import/p6.cpp +++ b/clang/test/CXX/module/module.import/p6.cpp @@ -28,3 +28,11 @@ static const int value = 43; }; +void deleted_fn_ok (void) = delete; + +struct S { + ~S() noexcept(false) = default; +private: + S(S&); +}; +S::S(S&) = default;