Implement all of P1825R0:
- implicitly movable entity can be an rvalue reference to non-volatile
automatic object.
- operand of throw-expression can be a function or catch-clause parameter
(support for function parameter has already been implemented).
- in the first overload resolution, the selected function no need to be
a constructor.
- in the first overload resolution, the first parameter of the selected
function no need to be an rvalue reference to the object's type.
This patch also removes the diagnostic `-Wreturn-std-move-in-c++11`.
Differential Revision: https://reviews.llvm.org/D88220
70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=cxx20 %s
|
|
// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
|
|
// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify=cxx11_14_17 %s
|
|
// cxx20-no-diagnostics
|
|
|
|
// Throwing
|
|
namespace test_throwing {
|
|
class Widget {
|
|
public:
|
|
Widget(Widget &&);
|
|
Widget(const Widget &) = delete;
|
|
};
|
|
|
|
void seven(Widget w) {
|
|
throw w; // Clang already do this implicit move before -std=c++20
|
|
}
|
|
} // namespace test_throwing
|
|
|
|
// Non-constructor conversion
|
|
namespace test_non_constructor_conversion {
|
|
class Widget {};
|
|
|
|
struct To {
|
|
operator Widget() const & = delete; // cxx11_14_17-note {{'operator Widget' has been explicitly marked deleted here}}
|
|
operator Widget() &&;
|
|
};
|
|
|
|
Widget nine() {
|
|
To t;
|
|
return t; // cxx11_14_17-error {{conversion function from 'test_non_constructor_conversion::To' to 'test_non_constructor_conversion::Widget' invokes a deleted function}}
|
|
}
|
|
} // namespace test_non_constructor_conversion
|
|
|
|
// By-value sinks
|
|
namespace test_by_value_sinks {
|
|
class Widget {
|
|
public:
|
|
Widget();
|
|
Widget(Widget &&);
|
|
Widget(const Widget &) = delete; // cxx11_14_17-note {{'Widget' has been explicitly marked deleted here}}
|
|
};
|
|
|
|
struct Fowl {
|
|
Fowl(Widget); // cxx11_14_17-note {{passing argument to parameter here}}
|
|
};
|
|
|
|
Fowl eleven() {
|
|
Widget w;
|
|
return w; // cxx11_14_17-error {{call to deleted constructor of 'test_by_value_sinks::Widget'}}
|
|
}
|
|
} // namespace test_by_value_sinks
|
|
|
|
// Slicing
|
|
namespace test_slicing {
|
|
class Base {
|
|
public:
|
|
Base();
|
|
Base(Base &&);
|
|
Base(Base const &) = delete; // cxx11_14_17-note {{'Base' has been explicitly marked deleted here}}
|
|
};
|
|
|
|
class Derived : public Base {};
|
|
|
|
Base thirteen() {
|
|
Derived result;
|
|
return result; // cxx11_14_17-error {{call to deleted constructor of 'test_slicing::Base'}}
|
|
}
|
|
} // namespace test_slicing
|