[C++20] [Modules] Mark exported all declarations as used

Close https://github.com/llvm/llvm-project/issues/85122

As the title suggested, it looks pretty sensible.
This commit is contained in:
Chuanqi Xu 2024-04-19 09:46:16 +08:00
parent 3090efc6b6
commit aac4d03423
2 changed files with 10 additions and 0 deletions

View File

@ -1003,6 +1003,10 @@ Decl *Sema::ActOnFinishExportDecl(Scope *S, Decl *D, SourceLocation RBraceLoc) {
}
}
// Anything exported from a module should never be considered unused.
for (auto *Exported : ED->decls())
Exported->markUsed(getASTContext());
return D;
}

View File

@ -0,0 +1,6 @@
// RUN: %clang_cc1 -std=c++20 %s -Wall -fsyntax-only -verify
// expected-no-diagnostics
export module a;
export constexpr auto a = []{};