blob: 3e429d411621b8ed16bbc3975e8c6586a4ecf986 [file] [log] [blame]
Douglas Gregor1edf5762012-06-28 21:43:01 +00001// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify -std=c++11 %s
Chandler Carruth03b77b32011-04-25 06:34:35 +00002
3template <class T>
4class A {
5 void foo() {
6 undeclared();
7 }
Francois Pichet81345182011-09-22 22:14:56 +00008 void foo2();
Chandler Carruth03b77b32011-04-25 06:34:35 +00009};
10
11template <class T>
12class B {
13 void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
David Majnemerea5092a2013-07-07 23:49:50 +000014 void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}}
15 void foo5() { } // expected-note {{previous definition is here}}
Francois Pichet6dc4c162011-11-18 23:47:17 +000016
17 friend void foo3() {
18 undeclared();
19 }
Chandler Carruth03b77b32011-04-25 06:34:35 +000020};
21
22
23template <class T>
David Majnemerea5092a2013-07-07 23:49:50 +000024void B<T>::foo5() { // expected-error {{redefinition of 'foo5'}}
Chandler Carruth03b77b32011-04-25 06:34:35 +000025}
26
27template <class T>
28void A<T>::foo2() {
29 undeclared();
30}
31
32
33template <class T>
34void foo3() {
35 undeclared();
36}
37
38template void A<int>::foo2();
39
40
41void undeclared()
42{
43
44}
45
46template <class T> void foo5() {} //expected-note {{previous definition is here}}
47template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}}
Francois Pichet81345182011-09-22 22:14:56 +000048
49
50
51namespace Inner_Outer_same_template_param_name {
52
53template <class T>
54class Outmost {
55public:
56 template <class T>
57 class Inner {
58 public:
59 void f() {
60 T* var;
61 }
62 };
63};
64
65}
66
Francois Pichete6664762012-02-22 08:25:53 +000067
68namespace PR11931 {
69
70template <typename RunType>
71struct BindState;
72
73 template<>
74struct BindState<void(void*)> {
75 static void Run() { }
76};
77
78class Callback {
79public:
80 typedef void RunType();
81
82 template <typename RunType>
83 Callback(BindState<RunType> bind_state) {
84 BindState<RunType>::Run();
85 }
86};
87
88
89Callback Bind() {
90 return Callback(BindState<void(void*)>());
91}
92
93}
Douglas Gregor1edf5762012-06-28 21:43:01 +000094
95namespace rdar11700604 {
96 template<typename T> void foo() = delete;
97
98 struct X {
99 X() = default;
100
101 template<typename T> void foo() = delete;
102 };
103}
104