[PATCH] D141908: [C++20][Modules] Handle defaulted and deleted functions in header units.
Iain Sandoe via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 18 23:34:26 PST 2023
iains updated this revision to Diff 490383.
iains added a comment.
rebased.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141908/new/
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,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();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141908.490383.patch
Type: text/x-patch
Size: 1441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230119/fa5af94d/attachment.bin>
More information about the cfe-commits
mailing list