Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / libcxx_valarray_hack.cpp
blob03dc5731299d9e0a87cf48fcbc1b6bc2601b1dcd
1 // RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify
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).
8 #ifdef BE_THE_HEADER
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() {}
18 extern template valarray<size_t>::valarray(size_t);
19 extern template valarray<size_t>::~valarray();
22 #else
24 #define BE_THE_HEADER
25 #include "libcxx_valarray_hack.cpp"
27 template<typename T> struct foo {
28 __attribute__((internal_linkage)) void x() {};
30 extern template void foo<int>::x(); // expected-error {{explicit instantiation declaration of 'x' with internal linkage}}
32 #endif