summaryrefslogtreecommitdiffstats
path: root/libcxx/test/language.support
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-28 13:35:41 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-28 13:35:41 +0000
commita391bc13235cc52893c8470bbc4ea1794b539a3c (patch)
tree53eb96b0dc2f3e318d1fbfc4748462e996fd59e2 /libcxx/test/language.support
parentf9c94093f99fabbd6a4f116ae30fcc9ef155adad (diff)
downloadbcm5719-llvm-a391bc13235cc52893c8470bbc4ea1794b539a3c.tar.gz
bcm5719-llvm-a391bc13235cc52893c8470bbc4ea1794b539a3c.zip
Corrected rethrow_if_nested
llvm-svn: 104943
Diffstat (limited to 'libcxx/test/language.support')
-rw-r--r--libcxx/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/libcxx/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/libcxx/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
index c3f0222e0a5..fe0c2a07a8b 100644
--- a/libcxx/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
+++ b/libcxx/test/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
@@ -22,19 +22,18 @@ class A
int data_;
public:
explicit A(int data) : data_(data) {}
+ virtual ~A() {}
friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
};
class B
- : public std::nested_exception
+ : public std::nested_exception,
+ public A
{
- int data_;
public:
- explicit B(int data) : data_(data) {}
- B(const B& b) : data_(b.data_) {}
-
- friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
+ explicit B(int data) : A(data) {}
+ B(const B& b) : A(b) {}
};
int main()
@@ -56,18 +55,35 @@ int main()
{
throw B(5);
}
- catch (const B& b0)
+ catch (const B& b)
{
try
{
- B b = b0;
- std::rethrow_if_nested(b);
- assert(false);
+ throw b;
}
- catch (const B& b)
+ catch (const A& a)
{
- assert(b == B(5));
+ try
+ {
+ std::rethrow_if_nested(a);
+ assert(false);
+ }
+ catch (const B& b)
+ {
+ assert(b == B(5));
+ }
}
}
}
+ {
+ try
+ {
+ std::rethrow_if_nested(1);
+ assert(true);
+ }
+ catch (...)
+ {
+ assert(false);
+ }
+ }
}
OpenPOWER on IntegriCloud