File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
clang/test/CXX/expr/expr.prim/expr.prim.req Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,21 @@ namespace std_example {
3737 static_assert (D<T1>);
3838 template <D T> struct D_check {}; // expected-note{{because 'short' does not satisfy 'D'}}
3939 using dc1 = D_check<short >; // expected-error{{constraints not satisfied for class template 'D_check' [with T = short]}}
40+
41+ template <typename T>
42+ concept C2 = requires (T a) {
43+ requires sizeof (a) == 4 ; // OK
44+ requires a == 0 ; // expected-error{{substitution into constraint expression resulted in a non-constant expression}}
45+ // expected-note@-1{{while checking the satisfaction of nested requirement requested here}}
46+ // expected-note@-2{{in instantiation of requirement here}}
47+ // expected-note@-3{{while checking the satisfaction of nested requirement requested here}}
48+ // expected-note@-6{{while substituting template arguments into constraint expression here}}
49+ // expected-note@-5{{function parameter 'a' with unknown value cannot be used in a constant expression}}
50+ // expected-note@-8{{declared here}}
51+ };
52+ static_assert (C2<int >); // expected-error{{static assertion failed}}
53+ // expected-note@-1{{while checking the satisfaction of concept 'C2<int>' requested here}}
54+ // expected-note@-2{{because 'int' does not satisfy 'C2'}}
4055}
4156
4257template <typename T>
Original file line number Diff line number Diff line change @@ -98,6 +98,15 @@ namespace std_example {
9898 using c1c2 = C_check<int *>; // expected-error{{constraints not satisfied for class template 'C_check' [with T = int *]}}
9999}
100100
101+ // typeid() of an expression becomes potentially evaluated if the expression is
102+ // of a polymorphic type.
103+ class X { virtual ~X (); };
104+ constexpr bool b = requires (X &x) { static_cast <int (*)[(typeid (x), 0 )]>(nullptr ); };
105+ // expected-warning@-1 {{left operand of comma operator has no effect}}
106+ // expected-warning@-2 {{variable length arrays in C++ are a Clang extension}}
107+ // expected-note@-3{{function parameter 'x' with unknown value cannot be used in a constant expression}}
108+ // expected-note@-4{{declared here}}
109+
101110namespace access_checks {
102111namespace in_requires_expression {
103112template <auto >
You can’t perform that action at this time.
0 commit comments