llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr
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
..
PR20855_tuple_ref_binding_diagnostics.pass.cpp [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple. 2018-01-24 22:14:01 +00:00
PR22806_constrain_tuple_like_ctor.pass.cpp Update all bug URL's to point to https://bugs.llvm.org/... 2017-02-17 08:37:03 +00:00
PR23256_constrain_UTypes_ctor.pass.cpp Fix unused parameters and variables 2016-12-23 23:37:52 +00:00
PR27684_contains_ref_to_incomplete_type.pass.cpp Fix PR27684 - std::tuple no longer accepts reference to incomplete type in some cases. 2016-06-21 23:19:13 +00:00
PR31384.pass.cpp Fix unused parameters and variables 2016-12-23 23:37:52 +00:00
UTypes.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
UTypes.pass.cpp Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable 2017-10-14 15:52:38 +00:00
alloc.pass.cpp Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable 2017-10-14 15:52:38 +00:00
alloc_UTypes.pass.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
alloc_const_Types.fail.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
alloc_const_Types.pass.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
alloc_const_pair.pass.cpp [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7. 2016-12-08 21:38:32 +00:00
alloc_convert_copy.fail.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
alloc_convert_copy.pass.cpp [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7. 2016-12-08 21:38:32 +00:00
alloc_convert_move.fail.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
alloc_convert_move.pass.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
alloc_copy.pass.cpp Guard testing of tuple extensions to make tests portable 2016-05-27 22:41:45 +00:00
alloc_move.pass.cpp Guard testing of tuple extensions to make tests portable 2016-05-27 22:41:45 +00:00
alloc_move_pair.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
const_Types.fail.cpp Make tuples constructors conditionally EXPLICIT. See N4387 2016-04-19 01:19:25 +00:00
const_Types.pass.cpp Fix unused parameters and variables 2016-12-23 23:37:52 +00:00
const_Types2.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
const_pair.pass.cpp [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7. 2016-12-08 21:38:32 +00:00
convert_copy.pass.cpp [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7. 2016-12-08 21:38:32 +00:00
convert_move.pass.cpp [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7. 2016-12-08 21:38:32 +00:00
copy.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 2015-02-19 02:10:42 +00:00
copy.pass.cpp [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER. 2016-11-04 20:26:59 +00:00
default.pass.cpp Placate unused variable warnings uncovered by improvements to clang's -Wunused-variable 2017-10-14 15:52:38 +00:00
dtor.pass.cpp [libcxx] [test] Strip trailing whitespace. NFC. 2017-06-20 21:00:02 +00:00
implicit_deduction_guides.pass.cpp Add C++17 explicit deduction guides to std::pair. 2017-10-04 00:04:26 +00:00
move.pass.cpp Fix unused parameters and variables 2016-12-23 23:37:52 +00:00
move_pair.pass.cpp [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7. 2016-12-08 21:38:32 +00:00
test_lazy_sfinae.pass.cpp Make tuple_constructible and family lazy again. 2016-07-02 00:58:17 +00:00
tuple_array_template_depth.pass.cpp Mark more tuple tests as unsupported in C++98 && C++03 2015-02-19 02:44:09 +00:00