Author: Corentin Jabot Date: 2025-07-23T14:25:32+03:00 New Revision: 3affbce84342a80a0d869720353786d0db62ff4b
URL: https://github.com/llvm/llvm-project/commit/3affbce84342a80a0d869720353786d0db62ff4b DIFF: https://github.com/llvm/llvm-project/commit/3affbce84342a80a0d869720353786d0db62ff4b.diff LOG: [Clang] Fix a crash on invalid concept (#150186) Fixes #149986 Added: Modified: clang/lib/Sema/SemaConcept.cpp clang/test/SemaTemplate/concepts.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 5205ca0bca6fa..044cf5cf18d0a 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -588,6 +588,9 @@ static bool CheckConstraintSatisfaction( return true; for (const AssociatedConstraint &AC : AssociatedConstraints) { + if (AC.isNull()) + return true; + Sema::ArgPackSubstIndexRAII _(S, AC.ArgPackSubstIndex); ExprResult Res = calculateConstraintSatisfaction( S, Template, TemplateIDRange.getBegin(), TemplateArgsLists, diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index 62a4f95d79c74..663bc984ece2e 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1250,3 +1250,11 @@ static_assert(!D<Priv>::has, "Private should be invisible."); static_assert(!D<Prot>::has, "Protected should be invisible."); } + + +namespace GH149986 { +template <typename T> concept PerfectSquare = [](){} // expected-note 2{{here}} +([](auto) { return true; }) < PerfectSquare <class T>; +// expected-error@-1 {{declaration of 'T' shadows template parameter}} \ +// expected-error@-1 {{a concept definition cannot refer to itself}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits