ipa-cp: Perform operations in the appropriate types (PR 118097)
[gcc.git] / gcc / testsuite / g++.dg / concepts / expression2.C
blobc0eb4e545ffea1c99e668d0531565c4a40dc22db
1 // { dg-do compile { target c++17 } }
2 // { dg-options "-fconcepts" }
4 template<typename T>
5 concept C1 =
6   requires (T t) { t.f(); }; // { dg-message "in requirements" }
8 template<typename T>
9 concept C2 =
10   requires { typename T::type; }; // { dg-message "in requirements" }
12 template<typename T>
13   requires C1<T>
14 void f1(T x) { }
16 template<typename T>
17   requires C2<T>
18 void f2(T x) { }
20 // Note that these declarations are private and therefore
21 // cannot satisfy the constraints.
22 class S
24   using type = int;
25   void f() { }
26 } s;
28 int main()
30   f1(s); // { dg-error "no match" }
31   f2(s); // { dg-error "" }
33   // When used in non-SFINAE contexts, make sure that we fail
34   // the constraint check before emitting the access check
35   // failures. The context is being presented consistently
36   // in both cases.
37   static_assert(C1<S>, ""); // { dg-error "failed" }
38   static_assert(C2<S>, ""); // { dg-error "" }