brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 0270221 Raw
57 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s2// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++98 -Wc++11-compat %s3// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s4 5// Example from the standard6template<class T> class Array { void mf() { } }; 7 8template class Array<char>; 9template void Array<int>::mf();10template<class T> void sort(Array<T>& v) { /* ... */ }11template void sort(Array<char>&);12namespace N { 13  template<class T> void f(T&) { }14} 15template void N::f<int>(int&);16 17 18template<typename T>19struct X0 {20  struct Inner {};21  void f() { }22  static T value;23};24 25template<typename T>26T X0<T>::value = 17;27 28typedef X0<int> XInt;29 30template struct XInt::Inner; // expected-warning{{template-id}}31template void XInt::f(); // expected-warning{{template-id}}32template int XInt::value; // expected-warning{{template-id}}33 34namespace 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}42using namespace N;43 44template struct X1<int>;45#if __cplusplus <= 199711L46// expected-warning@-2 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}}47#else48// expected-error@-4 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}}49#endif50 51template void f1(int);52#if __cplusplus <= 199711L53// expected-warning@-2 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}}54#else55// expected-error@-4 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}}56#endif57