[PATCH] D141905: [C++20] [Modules] Only diagnose the non-inline external variable definitions in header units
Chuanqi Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 17 01:48:40 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3eb004ca78f: [C++20] [Modules] Only diagnose the non-inline external variable (authored by ChuanqiXu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141905/new/
https://reviews.llvm.org/D141905
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
@@ -22,3 +22,9 @@
int bad_var_definition = 3; // expected-error {{non-inline external definitions are not permitted in C++ header units}}
+class A {
+public:
+ // This is a declaration instead of definition.
+ static const int value = 43;
+};
+
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13088,6 +13088,7 @@
// C++ [module.import/6] external definitions are not permitted in header
// units.
if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
+ VDecl->isThisDeclarationADefinition() &&
VDecl->getFormalLinkage() == Linkage::ExternalLinkage &&
!VDecl->isInline()) {
Diag(VDecl->getLocation(), diag::err_extern_def_in_header_unit);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141905.489737.patch
Type: text/x-patch
Size: 1034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230117/5ccc8d34/attachment-0001.bin>
More information about the cfe-commits
mailing list