1 | // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s |
2 | // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++98 -Wc++11-compat %s |
3 | // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s |
4 | |
5 | // Example from the standard |
6 | template<class T> class Array { void mf() { } }; |
7 | |
8 | template class Array<char>; |
9 | template void Array<int>::mf(); |
10 | template<class T> void sort(Array<T>& v) { /* ... */ } |
11 | template void sort(Array<char>&); |
12 | namespace N { |
13 | template<class T> void f(T&) { } |
14 | } |
15 | template void N::f<int>(int&); |
16 | |
17 | |
18 | template<typename T> |
19 | struct X0 { |
20 | struct Inner {}; |
21 | void f() { } |
22 | static T value; |
23 | }; |
24 | |
25 | template<typename T> |
26 | T X0<T>::value = 17; |
27 | |
28 | typedef X0<int> XInt; |
29 | |
30 | template struct XInt::Inner; // expected-warning{{template-id}} |
31 | template void XInt::f(); // expected-warning{{template-id}} |
32 | template int XInt::value; // expected-warning{{template-id}} |
33 | |
34 | namespace N { |
35 | template<typename T> |
36 | struct X1 { // expected-note{{explicit instantiation refers here}} |
37 | }; |
38 | |
39 | template<typename T> |
40 | void f1(T) {} // expected-note{{explicit instantiation refers here}} |
41 | } |
42 | using namespace N; |
43 | |
44 | template struct X1<int>; |
45 | #if __cplusplus <= 199711L |
46 | // expected-warning@-2 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}} |
47 | #else |
48 | // expected-error@-4 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}} |
49 | #endif |
50 | |
51 | template void f1(int); |
52 | #if __cplusplus <= 199711L |
53 | // expected-warning@-2 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}} |
54 | #else |
55 | // expected-error@-4 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}} |
56 | #endif |
57 | |