Debian Codegraph @

clang/test/SemaCXX/libcxx_valarray_hack.cpp

raw
1 // RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify
2
3 // This is a test for a hack in Clang that works around an issue with libc++'s
4 // <valarray> implementation. The <valarray> header contains explicit
5 // instantiations of functions that it declared with the internal_linkage
6 // attribute, which are ill-formed by [temp.explicit]p13 (and meaningless).
7
8 #ifdef BE_THE_HEADER
9
10 #pragma GCC system_header
11 namespace std {
12 using size_t = __SIZE_TYPE__;
13 template<typename T> struct valarray {
14 __attribute__((internal_linkage)) valarray(size_t) {}
15 __attribute__((internal_linkage)) ~valarray() {}
16 };
17
18 extern template valarray<size_t>::valarray(size_t);
19 extern template valarray<size_t>::~valarray();
20 }
21
22 #else
23
24 #define BE_THE_HEADER
25 #include "libcxx_valarray_hack.cpp"
26
27 template<typename T> struct foo {
28 __attribute__((internal_linkage)) void x() {};
29 };
30 extern template void foo<int>::x(); // expected-error {{explicit instantiation declaration of 'x' with internal linkage}}
31
32 #endif