summaryrefslogtreecommitdiff
path: root/test/incomplete_type.sh.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-07-19 20:19:37 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-07-19 20:19:37 +0000
commit081ea86d80df60bcbb5517868ec5f1afab6bf973 (patch)
tree09943f2017e8e7b3457914f3541c4e81b1bddee9 /test/incomplete_type.sh.cpp
parente8b3ec33ccb6f76caea7388317d5620b9c36de51 (diff)
[libcxxabi] When catching an exception of type nullptr_t with a handler of
pointer-to-member type, produce a null value of the right type. This fixes a bug where throwing an exception of type nullptr_t and catching it as a pointer-to-member would not guarantee to produce a null value in the catch handler. The fix is pretty simple: we statically allocate a constant null pointer-to-data-member representation and a constant null pointer-to-member-function representation, and produce the address of the relevant value as the adjusted pointer for the exception. git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@276016 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/incomplete_type.sh.cpp')
-rw-r--r--test/incomplete_type.sh.cpp40
1 files changed, 30 insertions, 10 deletions
diff --git a/test/incomplete_type.sh.cpp b/test/incomplete_type.sh.cpp
index 701a037..3f18d36 100644
--- a/test/incomplete_type.sh.cpp
+++ b/test/incomplete_type.sh.cpp
@@ -88,7 +88,9 @@ int main() {
assert(false);
} catch (int CompleteAtThrow::*) {
assert(false);
- } catch (int NeverDefined::*) {}
+ } catch (int NeverDefined::*p) {
+ assert(!p);
+ }
AssertIncompleteTypeInfoEquals(ReturnTypeInfoIncompleteMP(), typeid(int IncompleteAtThrow::*));
try {
ThrowIncompleteMP();
@@ -99,7 +101,9 @@ int main() {
assert(false);
} catch (IncompleteAtThrow**) {
assert(false);
- } catch (int IncompleteAtThrow::*) {}
+ } catch (int IncompleteAtThrow::*p) {
+ assert(!p);
+ }
AssertIncompleteTypeInfoEquals(ReturnTypeInfoIncompletePP(), typeid(IncompleteAtThrow**));
try {
@@ -107,7 +111,9 @@ int main() {
assert(false);
} catch (int IncompleteAtThrow::*) {
assert(false);
- } catch (IncompleteAtThrow**) {}
+ } catch (IncompleteAtThrow** p) {
+ assert(!p);
+ }
try {
ThrowIncompletePMP();
@@ -116,7 +122,9 @@ int main() {
assert(false);
} catch (IncompleteAtThrow**) {
assert(false);
- } catch (int IncompleteAtThrow::**) {}
+ } catch (int IncompleteAtThrow::**p) {
+ assert(!p);
+ }
AssertIncompleteTypeInfoEquals(ReturnTypeInfoCompleteMP(), typeid(int CompleteAtThrow::*));
try {
@@ -128,7 +136,9 @@ int main() {
assert(false);
} catch (CompleteAtThrow**) {
assert(false);
- } catch (int CompleteAtThrow::*) {}
+ } catch (int CompleteAtThrow::*p) {
+ assert(!p);
+ }
AssertIncompleteTypeInfoEquals(ReturnTypeInfoCompletePP(), typeid(CompleteAtThrow**));
try {
@@ -140,7 +150,9 @@ int main() {
assert(false);
} catch (int CompleteAtThrow::*) {
assert(false);
- } catch (CompleteAtThrow**) {}
+ } catch (CompleteAtThrow**p) {
+ assert(!p);
+ }
try {
ThrowCompletePMP();
@@ -153,22 +165,30 @@ int main() {
assert(false);
} catch (CompleteAtThrow**) {
assert(false);
- } catch (int CompleteAtThrow::**) {}
+ } catch (int CompleteAtThrow::**p) {
+ assert(!p);
+ }
#if __cplusplus >= 201103L
// Catch nullptr as complete type
try {
ThrowNullptr();
- } catch (int IncompleteAtThrow::*) {}
+ } catch (int IncompleteAtThrow::*p) {
+ assert(!p);
+ }
// Catch nullptr as an incomplete type
try {
ThrowNullptr();
- } catch (int CompleteAtThrow::*) {}
+ } catch (int CompleteAtThrow::*p) {
+ assert(!p);
+ }
// Catch nullptr as a type that is never complete.
try {
ThrowNullptr();
- } catch (int NeverDefined::*) {}
+ } catch (int NeverDefined::*p) {
+ assert(!p);
+ }
#endif
}
#endif