Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / temp / temp.spec / temp.explicit / p2.cpp
blob027022176f81c74bb4671b5d0ccd69268efb522b
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
5 // Example from the standard
6 template<class T> class Array { void mf() { } };
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&) { }
15 template void N::f<int>(int&);
18 template<typename T>
19 struct X0 {
20 struct Inner {};
21 void f() { }
22 static T value;
25 template<typename T>
26 T X0<T>::value = 17;
28 typedef X0<int> XInt;
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}}
34 namespace N {
35 template<typename T>
36 struct X1 { // expected-note{{explicit instantiation refers here}}
39 template<typename T>
40 void f1(T) {} // expected-note{{explicit instantiation refers here}}
42 using namespace N;
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
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