iains created this revision. Herald added a project: All. iains added a reviewer: ChuanqiXu. iains published this revision for review. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Address part of https://github.com/llvm/llvm-project/issues/60079. Deleted and Defaulted functions are implicitly inline, but that state is not set at the point that we perform the diagnostic checks for externally- visible non-inline functions; check the function body type explicitly in the diagnostic. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D141908 Files: clang/lib/Sema/SemaDecl.cpp clang/test/CXX/module/module.import/p6.cpp Index: clang/test/CXX/module/module.import/p6.cpp =================================================================== --- clang/test/CXX/module/module.import/p6.cpp +++ 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; Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -15254,9 +15254,12 @@ } // 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). if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() && - FD->getFormalLinkage() == Linkage::ExternalLinkage && !FD->isInlined()) { + FD->getFormalLinkage() == Linkage::ExternalLinkage && + !FD->isInvalidDecl() && BodyKind == FnBodyKind::Other && + !FD->isInlined()) { Diag(FD->getLocation(), diag::err_extern_def_in_header_unit); FD->setInvalidDecl(); }
Index: clang/test/CXX/module/module.import/p6.cpp =================================================================== --- clang/test/CXX/module/module.import/p6.cpp +++ 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; Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -15254,9 +15254,12 @@ } // 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). if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() && - FD->getFormalLinkage() == Linkage::ExternalLinkage && !FD->isInlined()) { + FD->getFormalLinkage() == Linkage::ExternalLinkage && + !FD->isInvalidDecl() && BodyKind == FnBodyKind::Other && + !FD->isInlined()) { Diag(FD->getLocation(), diag::err_extern_def_in_header_unit); FD->setInvalidDecl(); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits