This extends the effects of [[ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1825r0.html | P1825 ]] to all C++ standards from C++11 up to C++20. According to Motion 23 from Cologne 2019, P1825R0 was accepted as a Defect Report, so we retroactively apply this all the way back to C++11. Note that we also remove implicit moves from C++98 as an extension altogether, since the expanded first overload resolution from P1825 can cause some meaning changes in C++98. For example it can change which copy constructor is picked when both const and non-const ones are available. This also rips out warn_return_std_move since there are no cases where it would be worthwhile to suggest it. This also fixes a bug with bailing into the second overload resolution when encountering a non-rvref qualified conversion operator. This was unnoticed until now, so two new test cases cover these. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D104500
69 lines
1.2 KiB
C++
69 lines
1.2 KiB
C++
// RUN: %clang_cc1 -std=c++2b -fsyntax-only -fcxx-exceptions -verify %s
|
|
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify %s
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify %s
|
|
// expected-no-diagnostics
|
|
|
|
// Throwing
|
|
namespace test_throwing {
|
|
class Widget {
|
|
public:
|
|
Widget(Widget &&);
|
|
Widget(const Widget &) = delete;
|
|
};
|
|
|
|
void seven(Widget w) {
|
|
throw w;
|
|
}
|
|
} // namespace test_throwing
|
|
|
|
// Non-constructor conversion
|
|
namespace test_non_constructor_conversion {
|
|
class Widget {};
|
|
|
|
struct To {
|
|
operator Widget() const & = delete;
|
|
operator Widget() &&;
|
|
};
|
|
|
|
Widget nine() {
|
|
To t;
|
|
return t;
|
|
}
|
|
} // namespace test_non_constructor_conversion
|
|
|
|
// By-value sinks
|
|
namespace test_by_value_sinks {
|
|
class Widget {
|
|
public:
|
|
Widget();
|
|
Widget(Widget &&);
|
|
Widget(const Widget &) = delete;
|
|
};
|
|
|
|
struct Fowl {
|
|
Fowl(Widget);
|
|
};
|
|
|
|
Fowl eleven() {
|
|
Widget w;
|
|
return w;
|
|
}
|
|
} // namespace test_by_value_sinks
|
|
|
|
// Slicing
|
|
namespace test_slicing {
|
|
class Base {
|
|
public:
|
|
Base();
|
|
Base(Base &&);
|
|
Base(Base const &) = delete;
|
|
};
|
|
|
|
class Derived : public Base {};
|
|
|
|
Base thirteen() {
|
|
Derived result;
|
|
return result;
|
|
}
|
|
} // namespace test_slicing
|