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 { public: EnumDecl *getEnumDecl() const { - return cast(EnumType->getType())->getOriginalDecl(); + return EnumType->getType()->castAs()->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(); } } + +namespace UsingUsingEnum { + namespace foo { + enum class EnumOne {}; + } + using foo::EnumOne; + + template void t() { + using enum EnumOne; + } + template void t(); +} // namespace UsingUsingEnum