Properly compute triviality for explicitly-defaulted or deleted special members.
Remove pre-standard restriction on explicitly-defaulted copy constructors with
'incorrect' parameter types, and instead just make those special members
non-trivial as the standard requires.
This required making CXXRecordDecl correctly handle classes which have both a
trivial and a non-trivial special member of the same kind.
This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the
new triviality computation technology.
llvm-svn: 169667
diff --git a/clang/test/SemaCXX/anonymous-struct.cpp b/clang/test/SemaCXX/anonymous-struct.cpp
index 19a88d7..8a61041 100644
--- a/clang/test/SemaCXX/anonymous-struct.cpp
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct S {
- S(); // expected-note {{because type 'S' has a user-declared constructor}}
+ S(); // expected-note {{because type 'S' has a user-provided default constructor}}
};
struct { // expected-error {{anonymous structs and classes must be class members}}
@@ -9,7 +9,7 @@
struct E {
struct {
- S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
+ S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
};
static struct {
};
diff --git a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
index 641760e..b1078dc 100644
--- a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -36,9 +36,9 @@
};
struct bad_decls {
- bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}} expected-error {{must be defaulted outside the class}}
+ bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}}
bad_decls&& operator = (bad_decls) = default; // expected-error {{lvalue reference}} expected-error {{must return 'bad_decls &'}}
- bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}} expected-error {{must be defaulted outside the class}}
+ bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}}
bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}}
};
@@ -57,14 +57,18 @@
~except_spec_d_good();
};
except_spec_d_good::~except_spec_d_good() = default;
-// FIXME: This should error in the virtual override check.
-// It doesn't because we generate the implicit specification later than
-// appropriate.
-struct except_spec_d_bad : except_spec_a, except_spec_b {
- ~except_spec_d_bad() = default;
+struct except_spec_d_good2 : except_spec_a, except_spec_b {
+ ~except_spec_d_good2() = default;
};
+struct except_spec_d_bad : except_spec_a, except_spec_b {
+ ~except_spec_d_bad() noexcept;
+};
+// FIXME: This should error because this exception spec is not
+// compatible with the implicit exception spec.
+except_spec_d_bad::~except_spec_d_bad() noexcept = default;
-// FIXME: This should error because the exceptions spec doesn't match.
+// FIXME: This should error because this exception spec is not
+// compatible with the implicit exception spec.
struct except_spec_d_mismatch : except_spec_a, except_spec_b {
except_spec_d_mismatch() throw(A) = default;
};
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
index d497d45..830ab9b 100644
--- a/clang/test/SemaCXX/cxx98-compat.cpp
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -254,13 +254,13 @@
namespace UnionOrAnonStructMembers {
struct NonTrivCtor {
- NonTrivCtor(); // expected-note 2{{user-declared constructor}}
+ NonTrivCtor(); // expected-note 2{{user-provided default constructor}}
};
struct NonTrivCopy {
- NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-declared copy constructor}}
+ NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-provided copy constructor}}
};
struct NonTrivDtor {
- ~NonTrivDtor(); // expected-note 2{{user-declared destructor}}
+ ~NonTrivDtor(); // expected-note 2{{user-provided destructor}}
};
union BadUnion {
NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial constructor is incompatible with C++98}}
@@ -338,8 +338,8 @@
namespace PR13480 {
struct basic_iterator {
- basic_iterator(const basic_iterator &it) {}
- basic_iterator(basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-declared copy constructor}}
+ basic_iterator(const basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-provided copy constructor}}
+ basic_iterator(basic_iterator &it) {}
};
union test {
@@ -349,12 +349,12 @@
namespace AssignOpUnion {
struct a {
- void operator=(const a &it) {}
- void operator=(a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-declared copy assignment operator}}
+ void operator=(const a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-provided copy assignment operator}}
+ void operator=(a &it) {}
};
struct b {
- void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-declared copy assignment operator}}
+ void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-provided copy assignment operator}}
};
union test1 {
@@ -364,9 +364,9 @@
}
namespace rdar11736429 {
- struct X {
+ struct X { // expected-note {{because type 'rdar11736429::X' has no default constructor}}
X(const X&) = delete; // expected-warning{{deleted function definitions are incompatible with C++98}} \
- // expected-note{{because type 'rdar11736429::X' has a user-declared constructor}}
+ // expected-note {{implicit default constructor suppressed by user-declared constructor}}
};
union S {