don't substitute through the constraints; that's only done when
they are checked. */
if (tree ci = get_constraints (t))
- set_constraints (r, ci);
+ /* Unless we're regenerating a lambda, in which case we'll set the
+ lambda's constraints in tsubst_lambda_expr. */
+ if (!lambda_fntype)
+ set_constraints (r, ci);
if (DECL_FRIEND_P (t) && DECL_FRIEND_CONTEXT (t))
SET_DECL_FRIEND_CONTEXT (r,
finish_member_declaration (fn);
}
+ if (tree ci = get_constraints (oldfn))
+ {
+ /* Substitute into the lambda's constraints. */
+ if (oldtmpl)
+ ++processing_template_decl;
+ ci = tsubst_constraint_info (ci, args, complain, in_decl);
+ if (oldtmpl)
+ --processing_template_decl;
+ set_constraints (fn, ci);
+ }
+
/* Let finish_function set this. */
DECL_DECLARED_CONSTEXPR_P (fn) = false;
--- /dev/null
+// PR c++/92838
+// { dg-do compile { target c++20 } }
+
+template<int N>
+auto foo()
+{
+ [] () requires (N != 0) { }(); // { dg-error "no match" }
+ [] () requires (N == 0) { }();
+
+ [] <int M=1> () requires (N == M) { }(); // { dg-error "no match" }
+ [] <int M=1> () requires (N != M) { }();
+}
+
+void bar()
+{
+ foo<0>();
+}
--- /dev/null
+// PR c++/92633
+// { dg-do compile { target c++20 } }
+
+template<class A, class B>
+concept different_than = !__is_same_as(A, B);
+
+template<class B>
+auto diff(B) {
+ return [](different_than<B> auto a) {};
+}
+
+int main() {
+ diff(42)("");
+ diff(42)(42); // { dg-error "no match" }
+}