Skip to content

Commit dfe216d

Browse files
committed
Add new tests for throwing incomplete pointer types
llvm-svn: 256323
1 parent 88b2688 commit dfe216d

File tree

1 file changed

+97
-18
lines changed

1 file changed

+97
-18
lines changed

libcxxabi/test/incomplete_type.sh.cpp

Lines changed: 97 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,52 @@
1414
// incomplete flags set, equality can be tested by comparing the type_info
1515
// addresses.
1616

17-
// RUN: %cxx %compile_flags -c %s -o %t.one.o
18-
// RUN: %cxx %compile_flags -c %s -o %t.two.o -DTU_ONE
19-
// RUN: %cxx %link_flags -o %t.exe %t.one.o %t.two.o
17+
// RUN: %cxx %flags %compile_flags -c %s -o %t.one.o
18+
// RUN: %cxx %flags %compile_flags -c %s -o %t.two.o -DTU_ONE
19+
// RUN: %cxx %flags %link_flags -o %t.exe %t.one.o %t.two.o
2020
// RUN: %t.exe
2121

2222
#include <stdio.h>
2323
#include <cassert>
2424
#include <typeinfo>
2525

2626
struct NeverDefined;
27-
void ThrowNeverDefined();
27+
void ThrowNeverDefinedMP();
2828

2929
struct IncompleteAtThrow;
30-
void ThrowIncomplete();
31-
std::type_info const& ReturnTypeInfoIncomplete();
30+
void ThrowIncompleteMP();
31+
void ThrowIncompletePP();
32+
void ThrowIncompletePMP();
33+
std::type_info const& ReturnTypeInfoIncompleteMP();
34+
std::type_info const& ReturnTypeInfoIncompletePP();
3235

3336
struct CompleteAtThrow;
34-
void ThrowComplete();
35-
std::type_info const& ReturnTypeInfoComplete();
37+
void ThrowCompleteMP();
38+
void ThrowCompletePP();
39+
void ThrowCompletePMP();
40+
std::type_info const& ReturnTypeInfoCompleteMP();
41+
std::type_info const& ReturnTypeInfoCompletePP();
3642

3743
void ThrowNullptr();
3844

3945
#ifndef TU_ONE
4046

41-
void ThrowNeverDefined() { throw (int NeverDefined::*)nullptr; }
47+
void ThrowNeverDefinedMP() { throw (int NeverDefined::*)nullptr; }
4248

43-
void ThrowIncomplete() { throw (int IncompleteAtThrow::*)nullptr; }
44-
std::type_info const& ReturnTypeInfoIncomplete() { return typeid(int IncompleteAtThrow::*); }
49+
void ThrowIncompleteMP() { throw (int IncompleteAtThrow::*)nullptr; }
50+
void ThrowIncompletePP() { throw (IncompleteAtThrow**)nullptr; }
51+
void ThrowIncompletePMP() { throw (int IncompleteAtThrow::**)nullptr; }
52+
53+
std::type_info const& ReturnTypeInfoIncompleteMP() { return typeid(int IncompleteAtThrow::*); }
54+
std::type_info const& ReturnTypeInfoIncompletePP() { return typeid(IncompleteAtThrow**); }
4555

4656
struct CompleteAtThrow {};
47-
void ThrowComplete() { throw (int CompleteAtThrow::*)nullptr; }
48-
std::type_info const& ReturnTypeInfoComplete() { return typeid(int CompleteAtThrow::*); }
57+
void ThrowCompleteMP() { throw (int CompleteAtThrow::*)nullptr; }
58+
void ThrowCompletePP() { throw (CompleteAtThrow**)nullptr; }
59+
void ThrowCompletePMP() { throw (int CompleteAtThrow::**)nullptr; }
60+
61+
std::type_info const& ReturnTypeInfoCompleteMP() { return typeid(int CompleteAtThrow::*); }
62+
std::type_info const& ReturnTypeInfoCompletePP() { return typeid(CompleteAtThrow**); }
4963

5064
void ThrowNullptr() { throw nullptr; }
5165

@@ -54,16 +68,81 @@ void ThrowNullptr() { throw nullptr; }
5468
struct IncompleteAtThrow {};
5569

5670
int main() {
57-
assert(ReturnTypeInfoIncomplete() != typeid(int IncompleteAtThrow::*));
5871
try {
59-
ThrowIncomplete();
72+
ThrowNeverDefinedMP();
73+
assert(false);
74+
} catch (int IncompleteAtThrow::*) {
75+
assert(false);
76+
} catch (int CompleteAtThrow::*) {
77+
assert(false);
78+
} catch (int NeverDefined::*) {}
79+
80+
assert(ReturnTypeInfoIncompleteMP() != typeid(int IncompleteAtThrow::*));
81+
try {
82+
ThrowIncompleteMP();
83+
assert(false);
84+
} catch (CompleteAtThrow**) {
85+
assert(false);
86+
} catch (int CompleteAtThrow::*) {
87+
assert(false);
88+
} catch (IncompleteAtThrow**) {
89+
assert(false);
6090
} catch (int IncompleteAtThrow::*) {}
6191

62-
assert(ReturnTypeInfoComplete() != typeid(int CompleteAtThrow::*));
92+
assert(ReturnTypeInfoIncompletePP() != typeid(IncompleteAtThrow**));
93+
try {
94+
ThrowIncompletePP();
95+
assert(false);
96+
} catch (int IncompleteAtThrow::*) {
97+
assert(false);
98+
} catch (IncompleteAtThrow**) {}
99+
63100
try {
64-
ThrowComplete();
101+
ThrowIncompletePMP();
102+
assert(false);
103+
} catch (int IncompleteAtThrow::*) {
104+
assert(false);
105+
} catch (IncompleteAtThrow**) {
106+
assert(false);
107+
} catch (int IncompleteAtThrow::**) {}
108+
109+
assert(ReturnTypeInfoCompleteMP() != typeid(int CompleteAtThrow::*));
110+
try {
111+
ThrowCompleteMP();
112+
assert(false);
113+
} catch (IncompleteAtThrow**) {
114+
assert(false);
115+
} catch (int IncompleteAtThrow::*) {
116+
assert(false);
117+
} catch (CompleteAtThrow**) {
118+
assert(false);
65119
} catch (int CompleteAtThrow::*) {}
66120

121+
assert(ReturnTypeInfoCompletePP() != typeid(CompleteAtThrow**));
122+
try {
123+
ThrowCompletePP();
124+
assert(false);
125+
} catch (IncompleteAtThrow**) {
126+
assert(false);
127+
} catch (int IncompleteAtThrow::*) {
128+
assert(false);
129+
} catch (int CompleteAtThrow::*) {
130+
assert(false);
131+
} catch (CompleteAtThrow**) {}
132+
133+
try {
134+
ThrowCompletePMP();
135+
assert(false);
136+
} catch (IncompleteAtThrow**) {
137+
assert(false);
138+
} catch (int IncompleteAtThrow::*) {
139+
assert(false);
140+
} catch (int CompleteAtThrow::*) {
141+
assert(false);
142+
} catch (CompleteAtThrow**) {
143+
assert(false);
144+
} catch (int CompleteAtThrow::**) {}
145+
67146
#if __cplusplus >= 201103L
68147
// Catch nullptr as complete type
69148
try {
@@ -76,7 +155,7 @@ int main() {
76155
} catch (int CompleteAtThrow::*) {}
77156
// Catch nullptr as a type that is never complete.
78157
try {
79-
ThrowNeverDefined();
158+
ThrowNullptr();
80159
} catch (int NeverDefined::*) {}
81160
#endif
82161
}

0 commit comments

Comments
 (0)