llvm-project/libcxx/test/std/utilities/utility
Eric Fiselier c24e6dd3c8 [libc++] Extension: Make `move` and `forward` constexpr in C++11.
Summary:
`std::move` and `std::forward` were not marked constexpr in C++11.  This can be very damaging because it makes otherwise constant expressions non-constant. For example:

```
#include <utility>
template <class T>
struct Foo {
  constexpr Foo(T&& tx) :  t(std::move(tx)) {}
  T t;
};
[[clang::require_constant_initialization]] Foo<int> f(42); // Foo should be constant initialized but C++11 move is not constexpr. As a result `f` is an unsafe global.
```

This patch applies `constexpr` to `move` and `forward` as an extension in C++11. Normally the library is not allowed to add `constexpr` because it may be observable to the user. In particular adding constexpr may cause valid code to stop compiling. However these problems only happen in more complex situations, like making `__invoke(...)` constexpr. `forward` and `move` are simply enough that applying `constexpr` is safe. 

Note that libstdc++ has offered this extension since at least 4.8.1.

Most of the changes in this patch are simply test cleanups or additions. The main changes in the tests are:

* Fold all `forward_N.fail.cpp` tests into a single `forward.fail.cpp` test using -verify.
* Delete most `move_only_N.fail.cpp` tests because they weren't actually testing anything.
* Fold `move_copy.pass.cpp` and `move_only.pass.cpp` into a single `move.pass.cpp` test.
* Add return type and noexcept tests for `forward` and `move`.




Reviewers: rsmith, mclow.lists, EricWF

Subscribers: K-ballo, loladiro

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

llvm-svn: 282439
2016-09-26 20:55:02 +00:00
..
as_const Remove trailing whitespace in test suite. Approved by Marshall Clow. 2016-06-01 21:35:39 +00:00
declval Fix a handful of tests that fail in C++03 2015-07-28 07:31:50 +00:00
exchange Remove trailing whitespace in test suite. Approved by Marshall Clow. 2016-06-01 21:35:39 +00:00
forward [libc++] Extension: Make `move` and `forward` constexpr in C++11. 2016-09-26 20:55:02 +00:00
operators
pairs Fix pair::operator=(TupleLike&&). 2016-08-29 01:43:41 +00:00
utility.inplace Implement the in_place tags from p0032r3. 2016-07-23 22:19:19 +00:00
utility.swap Add is_swappable/is_nothrow_swappable traits 2016-04-21 23:38:59 +00:00
synopsis.pass.cpp [libcxx] Fix c++98 test failures. 2016-06-03 21:40:03 +00:00