[llvm-branch-commits] [clang] 99cfc87 - [C++20] [Modules] Handling merging predefined decls from std (#219151)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 1 01:28:43 PDT 2026
Author: Chuanqi Xu
Date: 2026-09-01T10:28:29+02:00
New Revision: 99cfc877e40b1fff9f006129db9f7895a7847ce3
URL: https://github.com/llvm/llvm-project/commit/99cfc877e40b1fff9f006129db9f7895a7847ce3
DIFF: https://github.com/llvm/llvm-project/commit/99cfc877e40b1fff9f006129db9f7895a7847ce3.diff
LOG: [C++20] [Modules] Handling merging predefined decls from std (#219151)
Close https://github.com/llvm/llvm-project/issues/218152
This was only reported in windows as MSSTL chose to implement std module
by wrapping the STL into extern "C++", which is different from libstdc++
and libc++.
But technically this is not specific to windows and we're able to
preoduce it in linux although we won't face it in linux.
(cherry picked from commit 52774473867e49b5891ab9381accf4e5a3ce0024)
Added:
clang/test/Modules/pr218152.cppm
Modified:
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 27fe259af3717..6a25a799aa219 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -18387,7 +18387,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
}
if (getLangOpts().CPlusPlus && Name && DC && StdNamespace &&
- DC->Equals(getStdNamespace())) {
+ DC->getRedeclContext()->Equals(getStdNamespace())) {
if (Name->isStr("bad_alloc")) {
// This is a declaration of or a reference to "std::bad_alloc".
isStdBadAlloc = true;
diff --git a/clang/test/Modules/pr218152.cppm b/clang/test/Modules/pr218152.cppm
new file mode 100644
index 0000000000000..c7b82372f42d6
--- /dev/null
+++ b/clang/test/Modules/pr218152.cppm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+export module fake_std;
+
+extern "C++" {
+namespace std {
+ using size_t = decltype(sizeof 0);
+ export enum class align_val_t : size_t {};
+} // namespace std
+
+export void *operator new(std::size_t, std::align_val_t);
+
+namespace std {
+void foo() { align_val_t x{}; }
+} // namespace std
+} // extern "C++"
More information about the llvm-branch-commits
mailing list