diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaTemplate/cxx2a-constraint-exprs.cpp | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp index bc093a0fc50..b45b57f6b92 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp @@ -39,8 +39,9 @@ namespace std_example { using dc1 = D_check<short>; // expected-error{{constraints not satisfied for class template 'D_check' [with T = short]}} template<typename T> - concept C2 = requires (T a) { // expected-note{{'a' declared here}} + concept C2 = requires (T a) { requires sizeof(a) == 4; // OK - requires a == 0; // expected-error{{constraint variable 'a' cannot be used in an evaluated context}} + requires a == 0; // expected-note{{because 'a == 0' would be invalid: constraint variable 'a' cannot be used in an evaluated context}} }; + static_assert(C2<int>); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static_assert failed}} }
\ No newline at end of file diff --git a/clang/test/SemaTemplate/cxx2a-constraint-exprs.cpp b/clang/test/SemaTemplate/cxx2a-constraint-exprs.cpp new file mode 100644 index 00000000000..a2a7232b4b8 --- /dev/null +++ b/clang/test/SemaTemplate/cxx2a-constraint-exprs.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -std=c++2a -verify %s + +// Make sure constraint expressions are unevaluated before being substituted +// into during satisfaction checking. + +template<typename T> constexpr int f() { return T::value; } +template<typename T> concept Foo = false && (f<int>(), true); +bool k = Foo<int>; +template<typename T> requires false && (f<int>(), true) struct S {}; +// expected-note@-1{{because}} +using s = S<int>; // expected-error {{constraints not satisfied}} +template<typename T> void foo() requires false && (f<int>(), true) { }; +// expected-note@-1{{because}} expected-note@-1{{candidate template ignored}} +int a = (foo<int>(), 0); // expected-error{{no matching function}} +template<typename T> void bar() requires requires { requires false && (f<int>(), true); } { }; +// expected-note@-1{{because}} expected-note@-1{{candidate template ignored}} +int b = (bar<int>(), 0); // expected-error{{no matching function}}
\ No newline at end of file |