llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/156127.diff


2 Files Affected:

- (modified) clang/include/clang/AST/DeclCXX.h (+1-1) 
- (modified) clang/test/SemaTemplate/using-decl.cpp (+12) 


``````````diff
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

``````````

</details>


https://github.com/llvm/llvm-project/pull/156127
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to