[clang] [clang] fix using enum redecl in template regression (PR #159996)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 21 10:53:16 PDT 2025
https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/159996
This fixes a regression reported here: https://github.com/llvm/llvm-project/pull/155313#issuecomment-3315883183
Since this regression was never released, there are no release notes.
>From ba72adf11519440ceffec0f47df7fecb8901117e Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Sun, 21 Sep 2025 14:50:34 -0300
Subject: [PATCH] [clang] fix using enum redecl in template regression
This fixes a regression reported here: https://github.com/llvm/llvm-project/pull/155313#issuecomment-3315883183
Since this regression was never released, there are no release notes.
---
clang/lib/Sema/SemaCXXScopeSpec.cpp | 5 +++--
clang/test/SemaCXX/cxx20-using-enum.cpp | 10 ++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp
index e89243b9d767a..97ba1a510cee4 100644
--- a/clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -220,10 +220,11 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS,
///
bool Sema::RequireCompleteEnumDecl(EnumDecl *EnumD, SourceLocation L,
CXXScopeSpec *SS) {
- if (EnumD->isCompleteDefinition()) {
+ if (EnumDecl *Def = EnumD->getDefinition();
+ Def && Def->isCompleteDefinition()) {
// If we know about the definition but it is not visible, complain.
NamedDecl *SuggestedDef = nullptr;
- if (!hasReachableDefinition(EnumD, &SuggestedDef,
+ if (!hasReachableDefinition(Def, &SuggestedDef,
/*OnlyNeedComplete*/ false)) {
// If the user is going to see an error here, recover by making the
// definition visible.
diff --git a/clang/test/SemaCXX/cxx20-using-enum.cpp b/clang/test/SemaCXX/cxx20-using-enum.cpp
index 775b65c5a8d8e..0ae6f4c9a07b6 100644
--- a/clang/test/SemaCXX/cxx20-using-enum.cpp
+++ b/clang/test/SemaCXX/cxx20-using-enum.cpp
@@ -288,4 +288,14 @@ struct S {
};
};
}
+
+namespace Redecl {
+ enum class A : int { X };
+ enum class A : int;
+ template <class> struct B {
+ using enum A;
+ using Z = decltype(X);
+ };
+ template struct B<int>;
+} // namespace Redecl
#endif
More information about the cfe-commits
mailing list