Skip to content

Commit 78a7397

Browse files
committed
[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: #155313 (comment) Since this regression was never released, there are no release notes.
1 parent da7ce52 commit 78a7397

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/include/clang/AST/DeclCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3826,7 +3826,7 @@ class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> {
38263826

38273827
public:
38283828
EnumDecl *getEnumDecl() const {
3829-
return cast<clang::EnumType>(EnumType->getType())->getOriginalDecl();
3829+
return EnumType->getType()->castAs<clang::EnumType>()->getOriginalDecl();
38303830
}
38313831

38323832
static UsingEnumDecl *Create(ASTContext &C, DeclContext *DC,

clang/test/SemaTemplate/using-decl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,15 @@ namespace UsingInGenericLambda {
1414
}
1515
void e() { c<int>(); }
1616
}
17+
18+
namespace UsingUsingEnum {
19+
namespace foo {
20+
enum class EnumOne {};
21+
}
22+
using foo::EnumOne;
23+
24+
template <class> void t() {
25+
using enum EnumOne;
26+
}
27+
template void t<void>();
28+
} // namespace UsingUsingEnum

0 commit comments

Comments
 (0)