blob: 77b47239f4c8baae8e9c64bacc05576f65525935 [file] [log] [blame]
Douglas Gregor09630172012-06-28 21:43:01 +00001// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify -std=c++11 %s
Chandler Carruth62395c92011-04-25 06:34:35 +00002
3template <class T>
4class A {
5 void foo() {
6 undeclared();
7 }
Francois Pichetfdde4702011-09-22 22:14:56 +00008 void foo2();
Chandler Carruth62395c92011-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}}
14 void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}}
Francois Pichet9d38dbc2011-11-18 23:47:17 +000015
16 friend void foo3() {
17 undeclared();
18 }
Chandler Carruth62395c92011-04-25 06:34:35 +000019};
20
21
22template <class T>
23void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}}
24}
25
26template <class T>
27void A<T>::foo2() {
28 undeclared();
29}
30
31
32template <class T>
33void foo3() {
34 undeclared();
35}
36
37template void A<int>::foo2();
38
39
40void undeclared()
41{
42
43}
44
45template <class T> void foo5() {} //expected-note {{previous definition is here}}
46template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}}
Francois Pichetfdde4702011-09-22 22:14:56 +000047
48
49
50namespace Inner_Outer_same_template_param_name {
51
52template <class T>
53class Outmost {
54public:
55 template <class T>
56 class Inner {
57 public:
58 void f() {
59 T* var;
60 }
61 };
62};
63
64}
65
Francois Pichetd77177a2012-02-22 08:25:53 +000066
67namespace PR11931 {
68
69template <typename RunType>
70struct BindState;
71
72 template<>
73struct BindState<void(void*)> {
74 static void Run() { }
75};
76
77class Callback {
78public:
79 typedef void RunType();
80
81 template <typename RunType>
82 Callback(BindState<RunType> bind_state) {
83 BindState<RunType>::Run();
84 }
85};
86
87
88Callback Bind() {
89 return Callback(BindState<void(void*)>());
90}
91
92}
Douglas Gregor09630172012-06-28 21:43:01 +000093
94namespace rdar11700604 {
95 template<typename T> void foo() = delete;
96
97 struct X {
98 X() = default;
99
100 template<typename T> void foo() = delete;
101 };
102}
103