33 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify2 3// This is a test for a hack in Clang that works around an issue with libc++'s4// <valarray> implementation. The <valarray> header contains explicit5// instantiations of functions that it declared with the internal_linkage6// attribute, which are ill-formed by [temp.explicit]p13 (and meaningless).7 8#ifdef BE_THE_HEADER9 10#pragma GCC system_header11namespace 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#else23 24#define BE_THE_HEADER25#include "libcxx_valarray_hack.cpp"26 27template<typename T> struct foo {28 __attribute__((internal_linkage)) void x() {};29};30extern template void foo<int>::x(); // expected-error {{explicit instantiation declaration of 'x' with internal linkage}}31 32#endif33