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/test/SemaCXX/unique_object_duplication.h
+6-70Lines changed: 6 additions & 70 deletions
Original file line number
Diff line number
Diff line change
@@ -165,81 +165,17 @@ namespace GlobalTest {
165
165
166
166
namespaceTemplateTest {
167
167
168
-
template <typename T>
169
-
int disallowedTemplate1 = 0; // hidden-warning {{'disallowedTemplate1<int>' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
170
-
171
-
template int disallowedTemplate1<int>; // hidden-note {{in instantiation of}}
172
-
173
-
174
-
// Should work for implicit instantiation as well
175
-
template <typename T>
176
-
int disallowedTemplate2 = 0; // hidden-warning {{'disallowedTemplate2<int>' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
// We never warn inside templates because it's frequently infeasible to actually
169
+
// fix the warning.
182
170
183
-
// Ensure we only get warnings for templates that are actually instantiated
184
171
template <typename T>
185
-
int maybeAllowedTemplate = 0; // Not instantiated, so no warning here
186
-
187
-
template <typename T>
188
-
int maybeAllowedTemplate<T*> = 1; // hidden-warning {{'maybeAllowedTemplate<int *>' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
189
-
190
-
template <>
191
-
int maybeAllowedTemplate<bool> = 2; // hidden-warning {{'maybeAllowedTemplate<bool>' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
192
-
193
-
template int maybeAllowedTemplate<int*>; // hidden-note {{in instantiation of}}
172
+
int allowedTemplate1 = 0;
194
173
195
-
196
-
197
-
// Should work the same for static class members
198
-
template <typename T>
199
-
structS {
200
-
staticint staticMember;
201
-
};
174
+
template int allowedTemplate1<int>;
202
175
203
176
template <typename T>
204
-
intS<T>::staticMember = 0;// Never instantiated
177
+
inlineintallowedTemplate2 = 0;
205
178
206
-
// T* specialization
207
-
template <typename T>
208
-
structS<T*> {
209
-
staticint staticMember;
210
-
};
211
-
212
-
template <typename T>
213
-
int S<T*>::staticMember = 1; // hidden-warning {{'staticMember' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
int S<T&>::staticMember = 2; // hidden-warning {{'staticMember' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
staticint staticLocal; // hidden-warning {{'staticLocal' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
235
-
return &staticLocal;
236
-
}
237
-
238
-
template <>
239
-
int* wrapper<int*>() {
240
-
staticint staticLocal; // hidden-warning {{'staticLocal' may be duplicated when built into a shared library: it is mutable, has hidden visibility, and external linkage}}
241
-
return &staticLocal;
242
-
}
179
+
template int allowedTemplate2<int>;
243
180
244
-
auto dummy = wrapper<bool>(); // hidden-note {{in instantiation of}}
0 commit comments