Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/concepts-complete3.C

raw
1 // Verify we diagnose an unstable satisfaction result that depends on
2 // return type deduction of the member function A::foo() below.
3 //
4 // { dg-do compile { target c++20 } }
5
6 template <class T> concept fooable = requires (T t) { t.foo(); };
7 // { dg-error "'false' to 'true'" "" { target *-*-* } .-1 }
8
9 template <fooable T> int f () { return 0; }
10 template <class T> char f() { return 0; }
11
12 struct A { auto foo(); };
13 static_assert (sizeof (f<A>()) == 1); // { dg-message "first evaluated to 'false' from here" }
14 auto A::foo() { }
15 static_assert (sizeof (f<A>()) > 1); // { dg-error "assert" }
16 static_assert (sizeof (f<A>()) > 1);