Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CXX / expr / expr.prim / expr.prim.req / p3.cpp
blobd2c8cd4fc2195e4e6d305cdaa3db5666056dcd6c
1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
3 // Examples from standard
5 template<typename T, typename U>
6 concept convertible_to = requires(T t) { U(t); };
8 template<typename T>
9 concept R = requires (T i) {
10 typename T::type;
11 {*i} -> convertible_to<const typename T::type&>;
14 template<typename T> requires R<T> struct S {};
16 struct T {
17 using type = int;
18 type i;
19 const type &operator*() { return i; }
22 using si = S<T>;
24 template<typename T>
25 requires requires (T x) { x + x; } // expected-note{{because 'x + x' would be invalid: invalid operands to binary expression ('T' and 'T')}}
26 T add(T a, T b) { return a + b; } // expected-note{{candidate template ignored: constraints not satisfied [with T = T]}}
28 int x = add(1, 2);
29 int y = add(T{}, T{}); // expected-error{{no matching function for call to 'add'}}
31 template<typename T>
32 concept C = requires (T x) { x + x; }; // expected-note{{because 'x + x' would be invalid: invalid operands to binary expression ('T' and 'T')}}
33 template<typename T> requires C<T> // expected-note{{because 'T' does not satisfy 'C'}}
34 T add2(T a, T b) { return a + b; } // expected-note{{candidate template ignored: constraints not satisfied [with T = T]}}
36 int z = add2(1, 2);
37 int w = add2(T{}, T{}); // expected-error{{no matching function for call to 'add2'}}