File: p4.cpp

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (49 lines) | stat: -rw-r--r-- 2,283 bytes parent folder | download | duplicates (29)
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
49
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %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); // expected-note{{previous template specialization is here}}
template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization has no effect}}

template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}}
template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization has no effect}}

template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}}
template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization has no effect}}

template<> long X0<long>::value; // expected-note{{previous template specialization is here}}
template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization has no effect}}

template<> struct X0<double>; // expected-note{{previous template specialization is here}}
template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization has no effect}}

// 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>; // expected-warning 0-1{{extern templates are a C++11 extension}}
  template class foo<char>;
}