Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -162,10 +162,10 @@ def DeprecatedArrayCompare : DiagGroup<"deprecated-array-compare">; def DeprecatedAttributes : DiagGroup<"deprecated-attributes">; def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">; -def DeprecatedCopyUserProvided : DiagGroup<"deprecated-copy-user-provided">; -def DeprecatedCopyDtorUserProvided : DiagGroup<"deprecated-copy-dtor-user-provided">; -def DeprecatedCopy : DiagGroup<"deprecated-copy", [DeprecatedCopyUserProvided]>; -def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyDtorUserProvided]>; +def DeprecatedCopyUserProvidedCopy : DiagGroup<"deprecated-copy-user-provided-copy">; +def DeprecatedCopyUserProvidedDtor : DiagGroup<"deprecated-copy-user-provided-dtor">; +def DeprecatedCopy : DiagGroup<"deprecated-copy", [DeprecatedCopyUserProvidedCopy]>; +def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", [DeprecatedCopyUserProvidedDtor]>; def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">; def UnavailableDeclarations : DiagGroup<"unavailable-declarations">; def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">; Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -567,21 +567,24 @@ def err_access_decl : Error< "ISO C++11 does not allow access declarations; " "use using declarations instead">; -def warn_deprecated_copy_operation : Warning< +def warn_deprecated_copy : Warning< "definition of implicit copy %select{constructor|assignment operator}1 " "for %0 is deprecated because it has a user-declared copy " "%select{assignment operator|constructor}1">, InGroup, DefaultIgnore; -def warn_deprecated_copy_dtor_operation : Warning< +def warn_deprecated_copy_dtor : Warning< "definition of implicit copy %select{constructor|assignment operator}1 " "for %0 is deprecated because it has a user-declared destructor">, InGroup, DefaultIgnore; -def warn_deprecated_copy_operation_user_provided : Warning< - warn_deprecated_copy_operation.Text>, - InGroup, DefaultIgnore; -def warn_deprecated_copy_dtor_operation_user_provided : Warning< - warn_deprecated_copy_dtor_operation.Text>, - InGroup, DefaultIgnore; +def warn_deprecated_copy_user_provided_copy: Warning< + "definition of implicit copy %select{constructor|assignment operator}1 " + "for %0 is deprecated because it has a user-provided copy " + "%select{assignment operator|constructor}1">, + InGroup, DefaultIgnore; +def warn_deprecated_copy_user_provided_dtor : Warning< + "definition of implicit copy %select{constructor|assignment operator}1 " + "for %0 is deprecated because it has a user-provided destructor">, + InGroup, DefaultIgnore; def warn_cxx17_compat_exception_spec_in_signature : Warning< "mangled name of %0 will change in C++17 due to non-throwing exception " "specification in function signature">, InGroup; Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -14054,14 +14054,14 @@ bool IsCopyAssignment = !isa(CopyOp); unsigned DiagID = (UDOIsUserProvided && UDOIsDestructor) - ? diag::warn_deprecated_copy_dtor_operation_user_provided + ? diag::warn_deprecated_copy_user_provided_dtor : (UDOIsUserProvided && !UDOIsDestructor) - ? diag::warn_deprecated_copy_operation_user_provided + ? diag::warn_deprecated_copy_user_provided_copy : (!UDOIsUserProvided && UDOIsDestructor) - ? diag::warn_deprecated_copy_dtor_operation - : diag::warn_deprecated_copy_operation; + ? diag::warn_deprecated_copy_dtor + : diag::warn_deprecated_copy; S.Diag(UserDeclaredOperation->getLocation(), DiagID) - << RD << /*copy assignment*/ IsCopyAssignment; + << RD << IsCopyAssignment; } } Index: clang/test/SemaCXX/deprecated-copy-dtor.cpp =================================================================== --- clang/test/SemaCXX/deprecated-copy-dtor.cpp +++ clang/test/SemaCXX/deprecated-copy-dtor.cpp @@ -1,29 +1,12 @@ // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -verify -// definitions for std::move -namespace std { -template struct remove_reference { typedef T type; }; -template struct remove_reference { typedef T type; }; -template struct remove_reference { typedef T type; }; - -template typename remove_reference::type &&move(T &&t); -} // namespace std - -class ITest { -public: - virtual ~ITest() = default; // expected-warning {{definition of implicit copy constructor for 'ITest' is deprecated because it has a user-declared destructor}} - virtual void testMethod() = 0; -}; - -class TestImpl : public ITest // expected-note {{in implicit copy constructor for 'ITest' first required here}} -{ +class A { public: - virtual void testMethod() override{}; + ~A() = default; // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared destructor}} }; -int main() { - TestImpl impl1; - TestImpl impl2 = std::move(impl1); // expected-note {{in implicit move constructor for 'TestImpl' first required here}} - return 0; -} \ No newline at end of file +void foo() { + A a1; + A a2 = a1; // expected-note {{in implicit copy constructor for 'A' first required here}} +} Index: clang/test/SemaCXX/deprecated-copy-user-provided-copy.cpp =================================================================== --- clang/test/SemaCXX/deprecated-copy-user-provided-copy.cpp +++ clang/test/SemaCXX/deprecated-copy-user-provided-copy.cpp @@ -1,10 +1,11 @@ // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-user-provided -verify +// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-user-provided-copy -verify struct A { - A &operator=(const A &); // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared copy assignment operator}} + A &operator=(const A &); // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-provided copy assignment operator}} }; void foo() { - A a1, a2(a1); // expected-note {{implicit copy constructor for 'A' first required here}} + A a1; + A a2(a1); // expected-note {{implicit copy constructor for 'A' first required here}} } Index: clang/test/SemaCXX/deprecated-copy-user-provided-dtor.cpp =================================================================== --- clang/test/SemaCXX/deprecated-copy-user-provided-dtor.cpp +++ clang/test/SemaCXX/deprecated-copy-user-provided-dtor.cpp @@ -1,12 +1,11 @@ // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor-user-provided -verify +// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-user-provided-dtor -verify struct A { - int *ptr; - ~A(); // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared destructor}} + ~A(); // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-provided destructor}} }; void foo() { - A a{}; - A b = a; // expected-note {{implicit copy constructor for 'A' first required here}} + A a1; + A a2(a1); // expected-note {{implicit copy constructor for 'A' first required here}} } Index: clang/test/SemaCXX/deprecated-copy.cpp =================================================================== --- clang/test/SemaCXX/deprecated-copy.cpp +++ clang/test/SemaCXX/deprecated-copy.cpp @@ -1,9 +1,18 @@ // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify -struct S { - int i; - S& operator=(const S&) = delete; // expected-warning {{definition of implicit copy constructor for 'S' is deprecated because it has a user-declared copy assignment operator}} +struct A { + A& operator=(const A&) = default; // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared copy assignment operator}} }; -S test(const S& s) { return S(s); } // expected-note {{implicit copy constructor for 'S' first required here}} \ No newline at end of file +struct B { + B& operator=(const B&) = delete; // expected-warning {{definition of implicit copy constructor for 'B' is deprecated because it has a user-declared copy assignment operator}} +}; + +void foo() { + A a1; + A a2(a1); // expected-note {{implicit copy constructor for 'A' first required here}} + + B b1; + B b2(b1); // expected-note {{implicit copy constructor for 'B' first required here}} +} Index: clang/test/SemaCXX/deprecated.cpp =================================================================== --- clang/test/SemaCXX/deprecated.cpp +++ clang/test/SemaCXX/deprecated.cpp @@ -83,21 +83,21 @@ #if __cplusplus >= 201103L namespace DeprecatedCopy { struct Assign { - Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-declared copy assignment operator}} + Assign &operator=(const Assign&); // expected-warning {{definition of implicit copy constructor for 'Assign' is deprecated because it has a user-provided copy assignment operator}} }; Assign a1, a2(a1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Assign' first required here}} struct Ctor { Ctor(); - Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-declared copy constructor}} + Ctor(const Ctor&); // expected-warning {{definition of implicit copy assignment operator for 'Ctor' is deprecated because it has a user-provided copy constructor}} }; Ctor b1, b2; void f() { b1 = b2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Ctor' first required here}} struct Dtor { ~Dtor(); - // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-declared destructor}} - // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-declared destructor}} + // expected-warning@-1 {{definition of implicit copy constructor for 'Dtor' is deprecated because it has a user-provided destructor}} + // expected-warning@-2 {{definition of implicit copy assignment operator for 'Dtor' is deprecated because it has a user-provided destructor}} }; Dtor c1, c2(c1); // expected-note {{implicit copy constructor for 'DeprecatedCopy::Dtor' first required here}} void g() { c1 = c2; } // expected-note {{implicit copy assignment operator for 'DeprecatedCopy::Dtor' first required here}} @@ -105,7 +105,8 @@ struct DefaultedDtor { ~DefaultedDtor() = default; // expected-warning {{definition of implicit copy constructor for 'DefaultedDtor' is deprecated because it has a user-declared destructor}} }; // expected-warning@-1 {{definition of implicit copy assignment operator for 'DefaultedDtor' is deprecated because it has a user-declared destructor}} - DefaultedDtor d1, d2(d1); // expected-note {{in implicit copy constructor for 'DeprecatedCopy::DefaultedDtor' first required here}} + DefaultedDtor d1; + DefaultedDtor d2(d1); // expected-note {{in implicit copy constructor for 'DeprecatedCopy::DefaultedDtor' first required here}} void h() { d1 = d2; } // expected-note {{in implicit copy assignment operator for 'DeprecatedCopy::DefaultedDtor' first required here}} } #endif