Author: Weibo He
Date: 2026-07-15T05:55:05Z
New Revision: 74822b4ee01f168f2d9a808594abb0c8936f5bbf

URL: 
https://github.com/llvm/llvm-project/commit/74822b4ee01f168f2d9a808594abb0c8936f5bbf
DIFF: 
https://github.com/llvm/llvm-project/commit/74822b4ee01f168f2d9a808594abb0c8936f5bbf.diff

LOG: [clang][Sema] Fix rejected-valid for explicit object parameters in 
dependent nested classes context (#209107)

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

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.md
    clang/lib/Sema/SemaType.cpp
    clang/test/SemaCXX/cxx2b-deducing-this.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index ef3f684dcbe51..760c973eb6a73 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -128,6 +128,7 @@ latest release, please see the [Clang Web 
Site](https://clang.llvm.org) or the
 ### Bug Fixes in This Version
 
 - Fixed a constraint comparison bug in partial ordering. (#GH182671)
+- Fixed a rejected-valid case that used an explicit object parameter in an 
out-of-line definition of a nested class member. (#GH136472)
 
 #### Bug Fixes to Compiler Builtins
 

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..5dfc5bbf50abd 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 definition of dependent nested class works
+template<class T>
+void S<T>::Nested::f(this auto) {}
+}
+
 namespace tpl_address {
 
 struct A {


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to