[clang] [clang][Sema] Fix rejected-valid for explicit object parameters in dependent nested classes context (PR #209107)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 13 01:34:38 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Weibo He (NewSigma)
<details>
<summary>Changes</summary>
In #<!-- -->89078, we banned explicit object parameters from several invalid contexts. This patch proposes we relax the restriction and allow entering contexts so that nested classes can be visited correctly.
Close #<!-- -->136472
---
Full diff: https://github.com/llvm/llvm-project/pull/209107.diff
3 Files Affected:
- (modified) clang/docs/ReleaseNotes.md (+1)
- (modified) clang/lib/Sema/SemaType.cpp (+2-1)
- (modified) clang/test/SemaCXX/cxx2b-deducing-this.cpp (+13)
``````````diff
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index bbd42848a98c2..604b1c50241d5 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -814,6 +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)
- 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/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 3f0a7304db2f9..96e42b2bf9fe7 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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/209107
More information about the cfe-commits
mailing list