llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple
Eric Fiselier 292617e700 [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.
Summary:
See https://bugs.llvm.org/show_bug.cgi?id=20855

Libc++ goes out of it's way to diagnose `std::tuple` constructions which are UB due to lifetime bugs caused by reference creation. For example:

```
// The 'const std::string&' is created *inside* the tuple constructor, and its lifetime is over before the end of the constructor call.
std::tuple<int, const std::string&> t(std::make_tuple(42, "abc"));
```

However, we are over-aggressive and we incorrectly diagnose cases such as:

```
void foo(std::tuple<int const&, int const&> const&);
foo(std::make_tuple(42, 42));
```

This patch fixes the incorrectly diagnosed cases, as well as converting the diagnostic to use the newly added Clang trait `__reference_binds_to_temporary`. The new trait allows us to diagnose cases we previously couldn't such as:

```
std::tuple<int, const std::string&> t(42, "abc");
```

Reviewers: rsmith, mclow.lists

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 323380
2018-01-24 22:14:01 +00:00
..
tuple.apply [libcxx] [test] Fix comment typos. 2017-02-05 22:48:20 +00:00
tuple.assign Revert r289727 due to PR31384 2016-12-15 06:34:54 +00:00
tuple.cnstr [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple. 2018-01-24 22:14:01 +00:00
tuple.creation Implement LWG 2773 - std::ignore should be constexpr. 2017-02-06 01:25:31 +00:00
tuple.elem Add another test_macros.h include I missed to tuple.by.type.pass.cpp 2017-11-22 12:29:17 +00:00
tuple.helper [libcxx] [test] Fix -Wmismatched-tags in tuple_size_structured_bindings.pass.cpp. 2017-06-20 21:10:53 +00:00
tuple.rel [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7. 2016-12-08 21:38:23 +00:00
tuple.special [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
tuple.swap [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
tuple.traits [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
TupleFunction.pass.cpp Replace __cplusplus comparisons and dialect __has_feature checks with TEST_STD_VER. 2016-06-14 21:31:42 +00:00
alloc_first.h
alloc_last.h