[PATCH] D26231: [Sema] Allow static_cast<T&&>(e) to check explicit conversions for non-reference-related types.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 2 19:22:15 PDT 2016
EricWF marked 2 inline comments as done.
EricWF added inline comments.
Comment at: lib/Sema/SemaCast.cpp:1148
+ // FIXME C++1z doesn't allow this conversions for xvalues.
> Actually, it does, but it's covered by p4. (p3 now only covers the special lvalue->xvalue case for `static_cast`, which is not permitted by p4.) It's fine for us to still handle this here, or to allow the p4 case to deal with it instead. It's probably better to keep handling it here, since we produce better diagnostics this way.
Cool sounds good. I knew p4 would end up handling it, but I wasn't sure if forwarding to p4 would allow previously ill-formed conversions. I tried to construct such a case but couldn't.
Comment at: lib/Sema/SemaCast.cpp:1171-1173
+ msg = SrcExpr->isLValue() ? diag::err_bad_lvalue_to_rvalue_cast
+ : diag::err_bad_rvalue_to_rvalue_cast;
> OK, so the idea here is that p4 will never apply in a case where the reference is reference-related to the source but not reference-compatible, and no other rules would let us static_cast to reference type? It would be good to add a comment explaining that, since it's not immediately obvious.
That's my understanding. I'll add a comment.
More information about the cfe-commits