Skip to content

Commit b36d728

Browse files
committed
add rvalue tests
1 parent ddc9719 commit b36d728

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang/test/SemaCXX/constant-expression-cxx14.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,14 @@ constexpr bool foo(int *i) {
13321332
static_assert(foo(nullptr), ""); // expected-note {{in call to 'foo(nullptr)'}}
13331333
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
13341334

1335+
constexpr bool foo_rvalue(int *i) {
1336+
int &&j = (int&&)*i;
1337+
// expected-note@-1 {{binding a reference to dereferenced null pointer is not allowed in a constant expression}}
1338+
return true;
1339+
}
1340+
static_assert(foo_rvalue(nullptr), ""); // expected-note {{in call to 'foo_rvalue(nullptr)'}}
1341+
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
1342+
13351343
int arr[3]; // expected-note {{declared here}}
13361344
constexpr bool f() { // cxx14_20-error {{constexpr function never produces a constant expression}}
13371345
int &r = arr[3]; // cxx14_20-note {{binding a reference to dereferenced one-past-the-end pointer is not allowed in a constant expression}} \

0 commit comments

Comments
 (0)