Skip to content

Commit 5af23bf

Browse files
committed
Keep existing tests but update expected errors and warnings
1 parent e108f4c commit 5af23bf

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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

4257
template<typename T>

clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
101110
namespace access_checks {
102111
namespace in_requires_expression {
103112
template<auto>

0 commit comments

Comments
 (0)