]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/temp/temp.spec/temp.explicit/p4.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / CXX / temp / temp.spec / temp.explicit / p4.cpp
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3
4 template<typename T> void f0(T); // expected-note{{here}}
5 template void f0(int); // expected-error{{explicit instantiation of undefined function template}}
6
7 template<typename T>
8 struct X0 {
9   struct Inner;
10   
11   void f1(); // expected-note{{here}}
12   
13   static T value; // expected-note{{here}}
14 };
15
16 template void X0<int>::f1(); // expected-error{{explicit instantiation of undefined member function}}
17
18 template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}}
19
20 template<> void f0(long); // expected-note{{previous template specialization is here}}
21 template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization has no effect}}
22
23 template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}}
24 template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization has no effect}}
25
26 template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}}
27 template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization has no effect}}
28
29 template<> long X0<long>::value; // expected-note{{previous template specialization is here}}
30 template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization has no effect}}
31
32 template<> struct X0<double>; // expected-note{{previous template specialization is here}}
33 template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization has no effect}}
34
35 // PR 6458
36 namespace test0 {
37   template <class T> class foo {
38     int compare(T x, T y);
39   };
40
41   template <> int foo<char>::compare(char x, char y);
42   template <class T> int foo<T>::compare(T x, T y) {
43     // invalid at T=char; if we get a diagnostic here, we're
44     // inappropriately instantiating this template.
45     void *ptr = x;
46   }
47   extern template class foo<char>; // expected-warning 0-1{{extern templates are a C++11 extension}}
48   template class foo<char>;
49 }