summaryrefslogtreecommitdiff
path: root/test/incomplete_type.sh.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-12-23 07:04:32 +0000
committerEric Fiselier <eric@efcs.ca>2015-12-23 07:04:32 +0000
commit0edb61e2e581758fc4cd4cd09fc588b3fc91a653 (patch)
treeca4d44ca052aa7621fd77ae3093b76127bba338d /test/incomplete_type.sh.cpp
parent1a034d70c8a7409787341234f2f9ae6e18399c1d (diff)
Add new tests for throwing incomplete pointer types
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@256323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/incomplete_type.sh.cpp')
-rw-r--r--test/incomplete_type.sh.cpp115
1 files changed, 97 insertions, 18 deletions
diff --git a/test/incomplete_type.sh.cpp b/test/incomplete_type.sh.cpp
index 111d133..a806c6d 100644
--- a/test/incomplete_type.sh.cpp
+++ b/test/incomplete_type.sh.cpp
@@ -14,9 +14,9 @@
// incomplete flags set, equality can be tested by comparing the type_info
// addresses.
-// RUN: %cxx %compile_flags -c %s -o %t.one.o
-// RUN: %cxx %compile_flags -c %s -o %t.two.o -DTU_ONE
-// RUN: %cxx %link_flags -o %t.exe %t.one.o %t.two.o
+// RUN: %cxx %flags %compile_flags -c %s -o %t.one.o
+// RUN: %cxx %flags %compile_flags -c %s -o %t.two.o -DTU_ONE
+// RUN: %cxx %flags %link_flags -o %t.exe %t.one.o %t.two.o
// RUN: %t.exe
#include <stdio.h>
@@ -24,28 +24,42 @@
#include <typeinfo>
struct NeverDefined;
-void ThrowNeverDefined();
+void ThrowNeverDefinedMP();
struct IncompleteAtThrow;
-void ThrowIncomplete();
-std::type_info const& ReturnTypeInfoIncomplete();
+void ThrowIncompleteMP();
+void ThrowIncompletePP();
+void ThrowIncompletePMP();
+std::type_info const& ReturnTypeInfoIncompleteMP();
+std::type_info const& ReturnTypeInfoIncompletePP();
struct CompleteAtThrow;
-void ThrowComplete();
-std::type_info const& ReturnTypeInfoComplete();
+void ThrowCompleteMP();
+void ThrowCompletePP();
+void ThrowCompletePMP();
+std::type_info const& ReturnTypeInfoCompleteMP();
+std::type_info const& ReturnTypeInfoCompletePP();
void ThrowNullptr();
#ifndef TU_ONE
-void ThrowNeverDefined() { throw (int NeverDefined::*)nullptr; }
+void ThrowNeverDefinedMP() { throw (int NeverDefined::*)nullptr; }
-void ThrowIncomplete() { throw (int IncompleteAtThrow::*)nullptr; }
-std::type_info const& ReturnTypeInfoIncomplete() { return typeid(int IncompleteAtThrow::*); }
+void ThrowIncompleteMP() { throw (int IncompleteAtThrow::*)nullptr; }
+void ThrowIncompletePP() { throw (IncompleteAtThrow**)nullptr; }
+void ThrowIncompletePMP() { throw (int IncompleteAtThrow::**)nullptr; }
+
+std::type_info const& ReturnTypeInfoIncompleteMP() { return typeid(int IncompleteAtThrow::*); }
+std::type_info const& ReturnTypeInfoIncompletePP() { return typeid(IncompleteAtThrow**); }
struct CompleteAtThrow {};
-void ThrowComplete() { throw (int CompleteAtThrow::*)nullptr; }
-std::type_info const& ReturnTypeInfoComplete() { return typeid(int CompleteAtThrow::*); }
+void ThrowCompleteMP() { throw (int CompleteAtThrow::*)nullptr; }
+void ThrowCompletePP() { throw (CompleteAtThrow**)nullptr; }
+void ThrowCompletePMP() { throw (int CompleteAtThrow::**)nullptr; }
+
+std::type_info const& ReturnTypeInfoCompleteMP() { return typeid(int CompleteAtThrow::*); }
+std::type_info const& ReturnTypeInfoCompletePP() { return typeid(CompleteAtThrow**); }
void ThrowNullptr() { throw nullptr; }
@@ -54,16 +68,81 @@ void ThrowNullptr() { throw nullptr; }
struct IncompleteAtThrow {};
int main() {
- assert(ReturnTypeInfoIncomplete() != typeid(int IncompleteAtThrow::*));
try {
- ThrowIncomplete();
+ ThrowNeverDefinedMP();
+ assert(false);
+ } catch (int IncompleteAtThrow::*) {
+ assert(false);
+ } catch (int CompleteAtThrow::*) {
+ assert(false);
+ } catch (int NeverDefined::*) {}
+
+ assert(ReturnTypeInfoIncompleteMP() != typeid(int IncompleteAtThrow::*));
+ try {
+ ThrowIncompleteMP();
+ assert(false);
+ } catch (CompleteAtThrow**) {
+ assert(false);
+ } catch (int CompleteAtThrow::*) {
+ assert(false);
+ } catch (IncompleteAtThrow**) {
+ assert(false);
} catch (int IncompleteAtThrow::*) {}
- assert(ReturnTypeInfoComplete() != typeid(int CompleteAtThrow::*));
+ assert(ReturnTypeInfoIncompletePP() != typeid(IncompleteAtThrow**));
+ try {
+ ThrowIncompletePP();
+ assert(false);
+ } catch (int IncompleteAtThrow::*) {
+ assert(false);
+ } catch (IncompleteAtThrow**) {}
+
try {
- ThrowComplete();
+ ThrowIncompletePMP();
+ assert(false);
+ } catch (int IncompleteAtThrow::*) {
+ assert(false);
+ } catch (IncompleteAtThrow**) {
+ assert(false);
+ } catch (int IncompleteAtThrow::**) {}
+
+ assert(ReturnTypeInfoCompleteMP() != typeid(int CompleteAtThrow::*));
+ try {
+ ThrowCompleteMP();
+ assert(false);
+ } catch (IncompleteAtThrow**) {
+ assert(false);
+ } catch (int IncompleteAtThrow::*) {
+ assert(false);
+ } catch (CompleteAtThrow**) {
+ assert(false);
} catch (int CompleteAtThrow::*) {}
+ assert(ReturnTypeInfoCompletePP() != typeid(CompleteAtThrow**));
+ try {
+ ThrowCompletePP();
+ assert(false);
+ } catch (IncompleteAtThrow**) {
+ assert(false);
+ } catch (int IncompleteAtThrow::*) {
+ assert(false);
+ } catch (int CompleteAtThrow::*) {
+ assert(false);
+ } catch (CompleteAtThrow**) {}
+
+ try {
+ ThrowCompletePMP();
+ assert(false);
+ } catch (IncompleteAtThrow**) {
+ assert(false);
+ } catch (int IncompleteAtThrow::*) {
+ assert(false);
+ } catch (int CompleteAtThrow::*) {
+ assert(false);
+ } catch (CompleteAtThrow**) {
+ assert(false);
+ } catch (int CompleteAtThrow::**) {}
+
#if __cplusplus >= 201103L
// Catch nullptr as complete type
try {
@@ -76,7 +155,7 @@ int main() {
} catch (int CompleteAtThrow::*) {}
// Catch nullptr as a type that is never complete.
try {
- ThrowNeverDefined();
+ ThrowNullptr();
} catch (int NeverDefined::*) {}
#endif
}