You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: clang-tools-extra/test/clang-tidy/cert-static-object-exception.cpp
+32-1
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,15 @@ struct V {
16
16
explicitV(constchar *) {} // Can throw
17
17
};
18
18
19
+
structCleanup
20
+
{
21
+
~Cleanup() {}
22
+
};
23
+
24
+
structW {
25
+
W(Cleanup c = {}) noexcept(false);
26
+
};
27
+
19
28
20
29
S s;
21
30
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 's' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
@@ -27,6 +36,9 @@ U u;
27
36
V v("v");
28
37
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
29
38
// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
39
+
W w;
40
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'w' with static storage duration may throw an exception that cannot be caught
41
+
// CHECK-MESSAGES: 25:3: note: possibly throwing constructor declared here
30
42
31
43
thread_local S s3;
32
44
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
@@ -35,22 +47,27 @@ thread_local U u3;
35
47
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
36
48
thread_local V v3("v");
37
49
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'v3' with thread_local storage duration may throw an exception that cannot be caught
50
+
thread_local W w3;
51
+
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'w3' with thread_local storage duration may throw an exception that cannot be caught
38
52
39
-
voidf(S s1, T t1, U u1, V v1) { // ok, ok, ok, ok
53
+
voidf(S s1, T t1, U u1, V v1, W w1) { // ok, ok, ok, ok, ok
40
54
S s2; // ok
41
55
T t2; // ok
42
56
U u2; // ok
43
57
V v2("v"); // ok
58
+
W w2; // ok
44
59
45
60
thread_local S s3; // ok
46
61
thread_local T t3; // ok
47
62
thread_local U u3; // ok
48
63
thread_local V v3("v"); // ok
64
+
thread_local W w3; // ok
49
65
50
66
static S s4; // ok
51
67
static T t4; // ok
52
68
static U u4; // ok
53
69
static V v4("v"); // ok
70
+
static W w4; // ok
54
71
}
55
72
56
73
namespace {
@@ -64,6 +81,9 @@ U u;
64
81
V v("v");
65
82
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
66
83
// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
84
+
W w;
85
+
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: construction of 'w' with static storage duration may throw an exception that cannot be caught
86
+
// CHECK-MESSAGES: 25:3: note: possibly throwing constructor declared here
67
87
68
88
thread_local S s3;
69
89
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 's3' with thread_local storage duration may throw an exception that cannot be caught
@@ -72,6 +92,8 @@ thread_local U u3;
72
92
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'u3' with thread_local storage duration may throw an exception that cannot be caught
73
93
thread_local V v3("v");
74
94
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'v3' with thread_local storage duration may throw an exception that cannot be caught
95
+
thread_local W w3;
96
+
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: construction of 'w3' with thread_local storage duration may throw an exception that cannot be caught
75
97
};
76
98
77
99
classStatics {
@@ -85,22 +107,28 @@ class Statics {
85
107
static V v;
86
108
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
87
109
// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
110
+
static W w;
111
+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'w' with static storage duration may throw an exception that cannot be caught
112
+
// CHECK-MESSAGES: 25:3: note: possibly throwing constructor declared here
88
113
89
114
voidf(S s, T t, U u, V v) {
90
115
S s2; // ok
91
116
T t2; // ok
92
117
U u2; // ok
93
118
V v2("v"); // ok
119
+
W w2; // ok
94
120
95
121
thread_local S s3; // ok
96
122
thread_local T t3; // ok
97
123
thread_local U u3; // ok
98
124
thread_local V v3("v"); // ok
125
+
thread_local W w3; // ok
99
126
100
127
static S s4; // ok
101
128
static T t4; // ok
102
129
static U u4; // ok
103
130
static V v4("v"); // ok
131
+
static W w4; // ok
104
132
}
105
133
};
106
134
@@ -114,3 +142,6 @@ U Statics::u;
114
142
V Statics::v("v");
115
143
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'v' with static storage duration may throw an exception that cannot be caught
116
144
// CHECK-MESSAGES: 16:12: note: possibly throwing constructor declared here
145
+
W Statics::w;
146
+
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: construction of 'w' with static storage duration may throw an exception that cannot be caught
147
+
// CHECK-MESSAGES: 25:3: note: possibly throwing constructor declared here
0 commit comments