blob: f302836c7e4b32553692dfb532c5c0642ad67583 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor5013a7e2009-09-24 23:39:01 +00002template<typename T>
3struct X0 {
4 typedef T* type;
5
6 void f0(T);
7 void f1(type);
8};
9
10template<> void X0<char>::f0(char);
11template<> void X0<char>::f1(type);
Douglas Gregor71ad4772010-02-16 19:28:15 +000012
13namespace PR6161 {
14 template<typename _CharT>
15 class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \
Douglas Gregor869853e2010-11-10 19:44:59 +000016 // expected-error{{expected class name}}
Douglas Gregor71ad4772010-02-16 19:28:15 +000017 {
Jeffrey Yasskin4e150f82010-04-07 23:29:58 +000018 static locale::id id; // expected-error{{use of undeclared identifier}}
Douglas Gregor71ad4772010-02-16 19:28:15 +000019 };
Richard Smith64e033f2015-01-15 00:48:52 +000020 numpunct<char>::~numpunct();
Douglas Gregor71ad4772010-02-16 19:28:15 +000021}
Richard Smith5001ec92013-07-02 18:08:50 +000022
23namespace PR12331 {
24 template<typename T> struct S {
25 struct U { static const int n = 5; };
26 enum E { e = U::n }; // expected-note {{implicit instantiation first required here}}
27 int arr[e];
28 };
29 template<> struct S<int>::U { static const int n = sizeof(int); }; // expected-error {{explicit specialization of 'U' after instantiation}}
30}
Richard Smith32983682013-12-14 03:18:05 +000031
32namespace PR18246 {
33 template<typename T>
34 class Baz {
35 public:
36 template<int N> void bar();
37 };
38
39 template<typename T>
40 template<int N>
Richard Smith11a80dc2014-04-17 03:52:20 +000041 void Baz<T>::bar() { // expected-note {{couldn't infer template argument 'N'}}
Richard Smith32983682013-12-14 03:18:05 +000042 }
43
Richard Smith11a80dc2014-04-17 03:52:20 +000044 // FIXME: We shouldn't try to match this against a prior declaration if
45 // template parameter matching failed.
Richard Smith32983682013-12-14 03:18:05 +000046 template<typename T>
Richard Smith11a80dc2014-04-17 03:52:20 +000047 void Baz<T>::bar<0>() { // expected-error {{cannot specialize a member of an unspecialized template}} \
48 // expected-error {{no function template matches}}
Richard Smith32983682013-12-14 03:18:05 +000049 }
50}
Richard Smith11a80dc2014-04-17 03:52:20 +000051
52namespace PR19340 {
53template<typename T> struct Helper {
54 template<int N> static void func(const T *m) {} // expected-note {{failed template argument deduction}}
55};
56
57template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}} \
58 // expected-error {{no function template matches}}
59}