]> granicus.if.org Git - clang/commit
[Sema] If lvalue to rvalue reference cast is valid don't emit diagnostic.
authorDavide Italiano <davide@freebsd.org>
Sun, 12 Jul 2015 22:10:56 +0000 (22:10 +0000)
committerDavide Italiano <davide@freebsd.org>
Sun, 12 Jul 2015 22:10:56 +0000 (22:10 +0000)
commit1c377036ee1772a07c7e5ae030e35ee499880245
tree77011a9cd653f6781aafb87e392187ff38946d3a
parentd6e98d6837549d53728315c6d64d5194c6248bd2
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241998 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaCast.cpp
test/SemaCXX/cast-lvalue-to-rvalue-reference.cpp [new file with mode: 0644]