[clang] [clang] fix a crash for uses of a pseudo-destructor of enum without definition (PR #210424)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 20 08:51:05 PDT 2026
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/210424
>From 4385582e51d18fd2d37154eb131e0c20352e4ce0 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Fri, 17 Jul 2026 17:01:38 -0300
Subject: [PATCH] [clang] fix a crash for uses of a pseudo-destructor of enum
without definition
Lookup for the destuctor name in the object type only applies to record types.
Fixes #209808
---
clang/lib/Sema/SemaCXXScopeSpec.cpp | 2 +-
clang/test/SemaTemplate/destructor-template.cpp | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp
index 00a566cfab7b0..58da58ca3c899 100644
--- a/clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -41,7 +41,7 @@ static CXXRecordDecl *getCurrentInstantiationOf(QualType T,
DeclContext *Sema::computeDeclContext(QualType T) {
if (!T->isDependentType())
- if (auto *D = T->getAsTagDecl())
+ if (auto *D = T->getAsRecordDecl())
return D;
return ::getCurrentInstantiationOf(T, CurContext);
}
diff --git a/clang/test/SemaTemplate/destructor-template.cpp b/clang/test/SemaTemplate/destructor-template.cpp
index 734269e854e5d..ba98a440ae155 100644
--- a/clang/test/SemaTemplate/destructor-template.cpp
+++ b/clang/test/SemaTemplate/destructor-template.cpp
@@ -119,3 +119,10 @@ X::typo<T>::typ0::~typ0() {} // expected-error {{no member named 'typ0'}} \
// expected-error {{no type named 'typ0'}}
}
+
+namespace GH209908 {
+ template <class T> using X = decltype(T().~E());
+ // expected-error at -1 {{undeclared identifier 'E' in destructor name}}
+ enum E : int;
+ using Z = X<E>; // expected-note {{requested here}}
+} // namespace GH209908
More information about the cfe-commits
mailing list