c++: change -fconcepts to mean C++20 concepts
[official-gcc.git] / gcc / testsuite / g++.dg / concepts / diagnostic1.C
blob207c36c320e48a9110b5e46dd8b9fc3b3cc3f741
1 // PR c++/67159
2 // { dg-do compile { target c++17_only } }
3 // { dg-options "-fconcepts-ts -fconcepts-diagnostics-depth=2" }
5 template <class T, class U>
6 concept bool SameAs = __is_same_as(T, U);
8 template <class T>
9 concept bool R1 = requires (T& t) { // { dg-message "in requirements" }
10   { t.begin() } -> T;           // { dg-error "no match" }
11   { t.end() } -> SameAs<T*>;    // { dg-message "does not satisfy" }
14 template <class T>
15 concept bool R2 = requires (T& t) { // { dg-message "in requirements" }
16   { t.end() } -> SameAs<T*>;    // { dg-message "does not satisfy" }
19 struct foo {
20   int* begin();
21   int* end();
24 R1{T}
25 constexpr bool f() { return true; }
27 R2{T}
28 constexpr bool g() { return true; }
30 static_assert(f<foo>());        // { dg-error "" }
31 static_assert(g<foo>());        // { dg-error "" }