summaryrefslogtreecommitdiffstats
path: root/test/CXX/special
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-06 22:04:06 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-06 22:04:06 +0000
commitbca01b46850f867b2f4137f25c882022b58f8471 (patch)
tree5de9b1e8664ced5008c6cab6a59bf1f96f5841bf /test/CXX/special
parenta26b2e5ab6ceac8035d31131906b4979b7e315bd (diff)
Properly implement the scope restriction on the NRVO for
throw-expressions, such that we don't consider the NRVO when the non-volatile automatic object comes from outside the innermost try scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were incorrect but it didn't matter because IR generation doesn't actually apply the NRVO here. In C++0x, however, we were moving from an object when in fact we should have copied from it. Fixes PR10142 / <rdar://problem/9714312>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134548 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/special')
-rw-r--r--test/CXX/special/class.copy/p33-0x.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/CXX/special/class.copy/p33-0x.cpp b/test/CXX/special/class.copy/p33-0x.cpp
index 1e6a025ef3..b196865c82 100644
--- a/test/CXX/special/class.copy/p33-0x.cpp
+++ b/test/CXX/special/class.copy/p33-0x.cpp
@@ -23,3 +23,35 @@ void throw_move_only(X x) {
throw x2;
}
+namespace PR10142 {
+ struct X {
+ X();
+ X(X&&);
+ X(const X&) = delete; // expected-note 2{{function has been explicitly marked deleted here}}
+ };
+
+ void f(int i) {
+ X x;
+ try {
+ X x2;
+ if (i)
+ throw x2; // okay
+ throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}}
+ } catch (...) {
+ }
+ }
+
+ template<typename T>
+ void f2(int i) {
+ T x;
+ try {
+ T x2;
+ if (i)
+ throw x2; // okay
+ throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}}
+ } catch (...) {
+ }
+ }
+
+ template void f2<X>(int); // expected-note{{in instantiation of function template specialization 'PR10142::f2<PR10142::X>' requested here}}
+}