https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/210424
Lookup for the destuctor name in the object type only applies to record types. Fixes #209808 >From 16b6c8da89872effded63637b343ff26e61be13f Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <[email protected]> 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/docs/ReleaseNotes.md | 3 +++ clang/lib/Sema/SemaCXXScopeSpec.cpp | 2 +- clang/test/SemaTemplate/destructor-template.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index 51dc07318e7ce..5bc5801054060 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -157,6 +157,9 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the #### Miscellaneous Clang Crashes Fixed +- Fixes a crash when using the pseudo-destructor for an enum without definition + through substitution in a template. (#GH209808) + ### OpenACC Specific Changes ### OpenCL Specific Changes 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@-1 {{undeclared identifier 'E' in destructor name}} + enum E : int; + using Z = X<E>; // expected-note {{requested here}} +} // namespace GH209908 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
