https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/208465

Fixes #206336

>From 07835592f82e6a7ca9f68a5a0566ef174133bbec Mon Sep 17 00:00:00 2001
From: Corentin Jabot <[email protected]>
Date: Thu, 9 Jul 2026 15:52:10 +0200
Subject: [PATCH] [Clang] Fix a crash when checking the constraints of a
 self-referential concept.

Fixes #206336
---
 clang/lib/Sema/SemaTemplate.cpp      |  1 +
 clang/test/SemaTemplate/concepts.cpp | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 1591cea9286ae..d2e22b0e63146 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -9306,6 +9306,7 @@ bool Sema::CheckConceptUseInDefinition(NamedDecl 
*Concept, SourceLocation Loc) {
       CE && !CE->isInvalidDecl() && !CE->hasDefinition()) {
     Diag(Loc, diag::err_recursive_concept) << CE;
     Diag(CE->getLocation(), diag::note_declared_at);
+    CE->setInvalidDecl();
     return true;
   }
   // Concept template parameters don't have a definition and can't
diff --git a/clang/test/SemaTemplate/concepts.cpp 
b/clang/test/SemaTemplate/concepts.cpp
index 6f7f00bf12e61..f690768476e7c 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -2064,3 +2064,19 @@ auto x = quantity<reference<int>{}, int>{};
 } // namespace CannotResolve1
 
 } // namespace GH175831
+
+
+namespace GH206336 {
+class Dim;
+struct S;
+template <class T> concept foo = true;
+template <class T> concept SS = false; // expected-note {{because 'false' 
evaluated to false}}
+template <class X> concept _Dim = _Dim<X>; // expected-error {{a concept 
definition cannot refer to itself}} \
+                                           // expected-note {{declared here}}
+template <SS, _Dim Dim, foo<> E> auto bar(Dim, E) {}; // expected-note 
{{candidate template ignored: constraints not satisfied}} \
+                                                      // expected-note 
{{because 'GH206336::S' does not satisfy 'SS'}}
+
+void baz() {
+  auto qux = bar<S>(true, [] {}); // expected-error {{no matching function for 
call to 'bar'}}
+}
+}

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

Reply via email to