https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/156127
Use the castAs acessor for the type for a UsingEnumDecl, as it can be sugar for an EnumType. Fixes a regression reported here: https://github.com/llvm/llvm-project/pull/155313#issuecomment-3238482327 Since this regression was never released, there are no release notes. >From 78a73973fb70ddcb51768489df7b273c45df9111 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <[email protected]> Date: Fri, 29 Aug 2025 21:16:55 -0300 Subject: [PATCH] [clang] fix obtaining EnumDecl for UsingEnumDecl Use the castAs acessor for the type for a UsingEnumDecl, as it can be sugar for an EnumType. Fixes a regression reported here: https://github.com/llvm/llvm-project/pull/155313#issuecomment-3238482327 Since this regression was never released, there are no release notes. --- clang/include/clang/AST/DeclCXX.h | 2 +- clang/test/SemaTemplate/using-decl.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 00d8f724671f1..8802664031d37 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -3826,7 +3826,7 @@ class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> { public: EnumDecl *getEnumDecl() const { - return cast<clang::EnumType>(EnumType->getType())->getOriginalDecl(); + return EnumType->getType()->castAs<clang::EnumType>()->getOriginalDecl(); } static UsingEnumDecl *Create(ASTContext &C, DeclContext *DC, diff --git a/clang/test/SemaTemplate/using-decl.cpp b/clang/test/SemaTemplate/using-decl.cpp index 1ef2a2dfaa019..d54d3a3f3ea9e 100644 --- a/clang/test/SemaTemplate/using-decl.cpp +++ b/clang/test/SemaTemplate/using-decl.cpp @@ -14,3 +14,15 @@ namespace UsingInGenericLambda { } void e() { c<int>(); } } + +namespace UsingUsingEnum { + namespace foo { + enum class EnumOne {}; + } + using foo::EnumOne; + + template <class> void t() { + using enum EnumOne; + } + template void t<void>(); +} // namespace UsingUsingEnum _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
