summaryrefslogtreecommitdiffstats
path: root/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
blob: 2b852136f303776347ebce98f5ef8c7f6e7d24b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RUN: %clang_cc1 -fsyntax-only -verify %s

template<typename T> void f0(T); // expected-note{{here}}
template void f0(int); // expected-error{{explicit instantiation of undefined function template}}

template<typename T>
struct X0 {
  struct Inner;
  
  void f1(); // expected-note{{here}}
  
  static T value; // expected-note{{here}}
};

template void X0<int>::f1(); // expected-error{{explicit instantiation of undefined member function}}

template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}}

template<> void f0(long);
template void f0(long); // okay

template<> void X0<long>::f1();
template void X0<long>::f1();

template<> struct X0<long>::Inner;
template struct X0<long>::Inner;

template<> long X0<long>::value;
template long X0<long>::value;

template<> struct X0<double>;
template struct X0<double>;

// PR 6458
namespace test0 {
  template <class T> class foo {
    int compare(T x, T y);
  };

  template <> int foo<char>::compare(char x, char y);
  template <class T> int foo<T>::compare(T x, T y) {
    // invalid at T=char; if we get a diagnostic here, we're
    // inappropriately instantiating this template.
    void *ptr = x;
  }
  extern template class foo<char>;
  template class foo<char>;
}
OpenPOWER on IntegriCloud