[clang] [clang][Sema] Fix rejected-valid for explicit object parameters in dependent nested classes context (PR #209107)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 14 05:54:29 PDT 2026
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/209107
>From 19c6bf4e7344aa51527066cc9c8840d82771e184 Mon Sep 17 00:00:00 2001
From: NewSigma <NewSigma at 163.com>
Date: Mon, 13 Jul 2026 16:19:35 +0800
Subject: [PATCH 1/2] [clang][Sema] Fix rejected-valid for explicit object
parameters in dependent nested classes context
---
clang/docs/ReleaseNotes.md | 1 +
clang/lib/Sema/SemaType.cpp | 3 ++-
clang/test/SemaCXX/cxx2b-deducing-this.cpp | 13 +++++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index a573599d76f7d..5cb523eb33e5a 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -789,6 +789,7 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the
- Fixed assertion failures involving code completion with delayed default arguments and exception specifications. (#GH200879)
- Fixed a regression where calling a function that takes a class-type parameter by value inside `decltype` of a concept could be incorrectly rejected when used as a non-type template argument. (#GH175831)
- Fixed a crash in the constant evaluator when an ill-formed array new-expression whose bound could not be determined (e.g. `new int[]()`) was used in a constant expression. (#GH200139)
+- Fixed a rejected-valid case that used explicit object parameters in the context of dependent nested classes. (#GH136472)
#### Bug Fixes to Compiler Builtins
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1378c7baca92e..5d80a3a0c8cbe 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -4890,7 +4890,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
// If there already was an problem with the scope, don’t issue another
// error about the explicit object parameter.
return SS.isInvalid() ||
- isa_and_present<CXXRecordDecl>(S.computeDeclContext(SS));
+ isa_and_present<CXXRecordDecl>(
+ S.computeDeclContext(SS, /*EnteringContext=*/true));
};
// C++23 [dcl.fct]p6:
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index b86731c7d7a11..539c8f8700fe7 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1170,6 +1170,19 @@ struct S {
};
}
+namespace GH136472 {
+template<class T>
+struct S {
+ struct Nested {
+ void f(this auto);
+ };
+};
+
+// Test that out-of-line member defination of dependent nested class works
+template<class T>
+void S<T>::Nested::f(this auto) {}
+}
+
namespace tpl_address {
struct A {
>From 50bf8e002e64b13e27917bef74bcb3d6d6b3f915 Mon Sep 17 00:00:00 2001
From: NewSigma <NewSigma at 163.com>
Date: Tue, 14 Jul 2026 20:05:26 +0800
Subject: [PATCH 2/2] resolve review comments
---
clang/docs/ReleaseNotes.md | 2 +-
clang/test/SemaCXX/cxx2b-deducing-this.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 604b1c50241d5..96d95212f9cee 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -814,7 +814,7 @@ latest release, please see the [Clang Web Site](https://clang.llvm.org) or the
would only use the first one). A new warning that diagnoses such declarations has been added to `-Wignored-attributes`.
(#GH191829)
- Fixed a crash in the constant evaluator when an ill-formed array new-expression whose bound could not be determined (e.g. `new int[]()`) was used in a constant expression. (#GH200139)
-- Fixed a rejected-valid case that used explicit object parameters in the context of dependent nested classes. (#GH136472)
+- Fixed a rejected-valid case that used an explicit object parameter in an out-of-line definition of a nested class member. (#GH136472)
- Clang now defines the GCC-compatible predefined macros `__WCHAR_MIN__`, `__WINT_MIN__`, and `__SIG_ATOMIC_MIN__`. (#GH199678)
- Fix a crash in addUnsizedArray due assert not verifying we have a Base before doing checks on it. (#GH44212)
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 539c8f8700fe7..5dfc5bbf50abd 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1178,7 +1178,7 @@ struct S {
};
};
-// Test that out-of-line member defination of dependent nested class works
+// Test that out-of-line member definition of dependent nested class works
template<class T>
void S<T>::Nested::f(this auto) {}
}
More information about the cfe-commits
mailing list