diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2022-06-22 09:15:53 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-08-21 10:19:46 +0100 |
commit | fee3cccc6cdabdeddc688cf7a15b144c814dd93d (patch) | |
tree | 1f47837db92f41cfe58b77b7cc56d76f59dfc96a /clang/lib/Sema/SemaModule.cpp | |
parent | 9a764ffeb6f06a87c7ad482ae39f8a38b3160c5e (diff) | |
download | llvm-fee3cccc6cdabdeddc688cf7a15b144c814dd93d.zip llvm-fee3cccc6cdabdeddc688cf7a15b144c814dd93d.tar.gz llvm-fee3cccc6cdabdeddc688cf7a15b144c814dd93d.tar.bz2 |
[C++20][Modules] Improve handing of Private Module Fragment diagnostics.
This adds a check for exported inline functions, that there is a definition in
the definition domain (which, in practice, can only be the module purview but
before any PMF starts) since the PMF definition domain cannot contain exports.
This is:
[dcl.inline]/7
If an inline function or variable that is attached to a named module is declared in
a definition domain, it shall be defined in that domain.
The patch also amends diagnostic output by excluding the PMF sub-module from the
set considered as sources of missing decls. There is no point in telling the user
that the import of a PMF object is missing - since such objects are never reachable
to an importer. We still show the definition (as unreachable), to help point out
this.
Differential Revision: https://reviews.llvm.org/D128328
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r-- | clang/lib/Sema/SemaModule.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index 757c611..b205fd9 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -910,6 +910,17 @@ Decl *Sema::ActOnFinishExportDecl(Scope *S, Decl *D, SourceLocation RBraceLoc) { diagExportedUnnamedDecl(*this, UnnamedDeclKind::Context, Child, BlockStart); } + if (auto *FD = dyn_cast<FunctionDecl>(Child)) { + // [dcl.inline]/7 + // If an inline function or variable that is attached to a named module + // is declared in a definition domain, it shall be defined in that + // domain. + // So, if the current declaration does not have a definition, we must + // check at the end of the TU (or when the PMF starts) to see that we + // have a definition at that point. + if (FD->isInlineSpecified() && !FD->isDefined()) + PendingInlineFuncDecls.insert(FD); + } } } |