14
14
// incomplete flags set, equality can be tested by comparing the type_info
15
15
// addresses.
16
16
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
20
20
// RUN: %t.exe
21
21
22
22
#include < stdio.h>
23
23
#include < cassert>
24
24
#include < typeinfo>
25
25
26
26
struct NeverDefined ;
27
- void ThrowNeverDefined ();
27
+ void ThrowNeverDefinedMP ();
28
28
29
29
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 ();
32
35
33
36
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 ();
36
42
37
43
void ThrowNullptr ();
38
44
39
45
#ifndef TU_ONE
40
46
41
- void ThrowNeverDefined () { throw (int NeverDefined::*)nullptr ; }
47
+ void ThrowNeverDefinedMP () { throw (int NeverDefined::*)nullptr ; }
42
48
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**); }
45
55
46
56
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**); }
49
63
50
64
void ThrowNullptr () { throw nullptr ; }
51
65
@@ -54,16 +68,81 @@ void ThrowNullptr() { throw nullptr; }
54
68
struct IncompleteAtThrow {};
55
69
56
70
int main () {
57
- assert (ReturnTypeInfoIncomplete () != typeid (int IncompleteAtThrow::*));
58
71
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 );
60
90
} catch (int IncompleteAtThrow::*) {}
61
91
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
+
63
100
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 );
65
119
} catch (int CompleteAtThrow::*) {}
66
120
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
+
67
146
#if __cplusplus >= 201103L
68
147
// Catch nullptr as complete type
69
148
try {
@@ -76,7 +155,7 @@ int main() {
76
155
} catch (int CompleteAtThrow::*) {}
77
156
// Catch nullptr as a type that is never complete.
78
157
try {
79
- ThrowNeverDefined ();
158
+ ThrowNullptr ();
80
159
} catch (int NeverDefined::*) {}
81
160
#endif
82
161
}
0 commit comments