Debian Codegraph @

gcc/testsuite/g++.dg/concepts/diagnostic1.C

raw
1 // PR c++/67159
2 // { dg-do compile { target c++17 } }
3 // { dg-options "-fconcepts -fconcepts-diagnostics-depth=2" }
4
5 template <class T, class U>
6 concept SameAs = __is_same_as(T, U);
7
8 template <class T>
9 concept R1 = requires (T& t) {
10 { t.begin() } -> T; // { dg-error "no matching|return-type-requirement|too many" }
11 { t.end() } -> SameAs<T*>; // { dg-error "deduced expression type" }
12 };
13
14 template <class T>
15 concept R2 = requires (T& t) {
16 { t.end() } -> SameAs<T*>; // { dg-error "deduced expression type" }
17 };
18
19 struct foo {
20 int* begin();
21 int* end();
22 };
23
24 template<R1 T>
25 constexpr bool f() { return true; }
26
27 template<R2 T>
28 constexpr bool g() { return true; }
29
30 static_assert(f<foo>()); // { dg-error "" }
31 static_assert(g<foo>()); // { dg-error "" }