Go to file
Eric Fiselier e4e9e281a1 [Sema] Allow static_cast<T&&>(e) to check explicit conversions for non-reference-related types.
Summary:
[expr.cast.static] states:
> 3. A glvalue of type “cv1 T1” can be cast to type “rvalue reference to cv2 T2” if “cv2 T2” is reference-compatible
> with “cv1 T1”. The result refers to the object or the specified base class subobject thereof. If T2 is
> an inaccessible or ambiguous base class of T1, a program that necessitates such a cast is
> ill-formed.
> 
> 4. Otherwise, an expression e can be explicitly converted to a type T using a static_cast of the form static_-
> cast<T>(e) if the declaration T t(e); is well-formed, for some invented temporary variable t. [...]

Currently when checking p3 Clang will diagnose `static_cast<T&&>(e)` as invalid if the argument is not reference compatible with `T`. However I believe the correct behavior is to also check p4 in those cases.  For example:

```
double y = 42;
static_cast<int&&>(y); // this should be OK.  'int&& t(y)' is well formed
```

Note that we still don't check p4 for non-reference-compatible types which are reference-related since  `T&& t(e);` should never be well formed in those cases.


Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D26231

llvm-svn: 285872
2016-11-03 02:13:17 +00:00
clang [Sema] Allow static_cast<T&&>(e) to check explicit conversions for non-reference-related types. 2016-11-03 02:13:17 +00:00
clang-tools-extra [clang-tidy] Suppress notes for warnings that were ignored 2016-11-02 21:14:22 +00:00
compiler-rt [asan] Add more dynamic CRT mode tests 2016-11-02 15:39:08 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc Provide vstore_half helper to workaround clc restrictions 2016-09-21 20:15:55 +00:00
libcxx Implement another part of P0031; adding constexpr to move_iterator 2016-11-02 15:30:26 +00:00
libcxxabi [p0012] Implement ABI support for throwing a noexcept function pointer and 2016-11-02 23:41:51 +00:00
libunwind Add support for old versions of MacOS to libunwind. Fixes PR22203. Thanks to Jeremy for the bug report and the patch. 2016-11-02 17:56:05 +00:00
lld Fix Windows buildbot. 2016-11-02 19:51:41 +00:00
lldb [cmake] Build gtest from LLVM when building standalone 2016-11-02 22:57:23 +00:00
llgo [llgo] add llgo source path to LLVM_GO_PACKAGES 2016-07-27 03:01:00 +00:00
llvm [ThinLTO] Handle distributed backend case when doing renaming 2016-11-03 01:07:16 +00:00
openmp Change task stealing to always get task from head of victim's deque. 2016-11-02 16:45:25 +00:00
parallel-libs [Acxxel] Remove setActiveDeviceForThread 2016-10-28 00:54:02 +00:00
polly [Polly CodeGen] Break critical edge from RTC to original loop. 2016-11-02 22:32:23 +00:00