summaryrefslogtreecommitdiffstats
path: root/clang/test/PCH/cxx0x-default-delete.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-12-08 08:32:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-12-08 08:32:28 +0000
commit6b02d46daeab3d3d06205f2ecf89fcd0f70a8bc8 (patch)
treefea2d0fe42a02fff7e6f1a6e1b93684b9f4ad4f0 /clang/test/PCH/cxx0x-default-delete.cpp
parent6ebca4be3300d3a9e45054b342ad4f8c58be3015 (diff)
downloadbcm5719-llvm-6b02d46daeab3d3d06205f2ecf89fcd0f70a8bc8.tar.gz
bcm5719-llvm-6b02d46daeab3d3d06205f2ecf89fcd0f70a8bc8.zip
Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial while building the class, we eagerly declare those special members. The impact of this is bounded, since it does not trigger implicit declarations of special members in classes which merely *use* those classes. In order to determine whether we need to apply this rule, we also need to eagerly declare move operations and destructors in cases where they might be deleted. If a move operation were supposed to be deleted, it would instead be suppressed, and we could need overload resolution to determine if we fall back to a trivial copy operation. If a destructor were implicitly deleted, it would cause the move constructor of any derived classes to be suppressed. As discussed on cxx-abi-dev, C++11's selected constructor rules are also retroactively applied as a defect resolution in C++03 mode, in order to identify that class B has a non-trivial copy constructor (since it calls A's constructor template, not A's copy constructor): struct A { template<typename T> A(T &); }; struct B { mutable A a; }; llvm-svn: 169673
Diffstat (limited to 'clang/test/PCH/cxx0x-default-delete.cpp')
-rw-r--r--clang/test/PCH/cxx0x-default-delete.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/PCH/cxx0x-default-delete.cpp b/clang/test/PCH/cxx0x-default-delete.cpp
index 39a90b858fd..230f6a61471 100644
--- a/clang/test/PCH/cxx0x-default-delete.cpp
+++ b/clang/test/PCH/cxx0x-default-delete.cpp
@@ -20,6 +20,11 @@ class quux {
~quux() = default;
};
+struct A {
+ A(const A&) = default;
+ template<typename T> A(T&&);
+};
+
#else
foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
@@ -31,4 +36,11 @@ void fn() {
baz bz; // expected-error{{deleted function}} expected-note@16{{deleted here}}
quux qx; // expected-error{{private destructor}} expected-note@20{{private here}}
+struct B { A a; };
+struct C { mutable A a; };
+static_assert(__is_trivially_constructible(B, const B&), "");
+static_assert(!__is_trivially_constructible(B, B&&), "");
+static_assert(!__is_trivially_constructible(C, const C&), "");
+static_assert(!__is_trivially_constructible(C, C&&), "");
+
#endif
OpenPOWER on IntegriCloud