diff options
| author | Davide Italiano <davide@freebsd.org> | 2015-07-12 22:10:56 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2015-07-12 22:10:56 +0000 |
| commit | a2275910a75457abacf024c9baf9f250b86439ed (patch) | |
| tree | 08b21338ccae5f553d125b2bbe1678cc38277d94 /clang/test | |
| parent | 28e28e8883d8f091d2351bb149125478885b0023 (diff) | |
| download | bcm5719-llvm-a2275910a75457abacf024c9baf9f250b86439ed.tar.gz bcm5719-llvm-a2275910a75457abacf024c9baf9f250b86439ed.zip | |
[Sema] If lvalue to rvalue reference cast is valid don't emit diagnostic.
In the test, y1 is not reference compatible to y2 and we currently assume
the cast is ill-formed so we emit a diagnostic. Instead, in order to honour
the standard, if y1 it's not reference-compatible to y2 then it can't be
converted using a static_cast, and a reinterpret_cast should be tried instead.
Richard Smith provided the correct interpretation of the standard and
explanation about the subtle difference between "can't be cast" and "the cast
is ill-formed". The former applies in this case.
PR: 23802
llvm-svn: 241998
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/SemaCXX/cast-lvalue-to-rvalue-reference.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cast-lvalue-to-rvalue-reference.cpp b/clang/test/SemaCXX/cast-lvalue-to-rvalue-reference.cpp new file mode 100644 index 00000000000..45e72d2924f --- /dev/null +++ b/clang/test/SemaCXX/cast-lvalue-to-rvalue-reference.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 +// expected-no-diagnostics + +struct S {}; +int x; +S&& y1 = (S&&)x; +S&& y2 = reinterpret_cast<S&&>(x); +S& z1 = (S&)x; |

