1fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s 262395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 362395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> 462395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthclass A { 562395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth void foo() { 662395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth undeclared(); 762395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth } 8fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet void foo2(); 962395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth}; 1062395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 1162395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> 1262395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthclass B { 1362395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}} 1462395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}} 159d38dbc9a16017fff3e34b7876a6590413a7d56bFrancois Pichet 169d38dbc9a16017fff3e34b7876a6590413a7d56bFrancois Pichet friend void foo3() { 179d38dbc9a16017fff3e34b7876a6590413a7d56bFrancois Pichet undeclared(); 189d38dbc9a16017fff3e34b7876a6590413a7d56bFrancois Pichet } 1962395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth}; 2062395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 2162395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 2262395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> 2362395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthvoid B<T>::foo4() {// expected-error {{redefinition of 'foo4'}} 2462395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth} 2562395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 2662395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> 2762395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthvoid A<T>::foo2() { 2862395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth undeclared(); 2962395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth} 3062395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 3162395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 3262395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> 3362395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthvoid foo3() { 3462395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth undeclared(); 3562395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth} 3662395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 3762395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate void A<int>::foo2(); 3862395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 3962395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 4062395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthvoid undeclared() 4162395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth{ 4262395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 4362395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth} 4462395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruth 4562395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> void foo5() {} //expected-note {{previous definition is here}} 4662395c9666b84bcb0cb322d5f5183472712685f6Chandler Carruthtemplate <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}} 47fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet 48fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet 49fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet 50fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichetnamespace Inner_Outer_same_template_param_name { 51fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet 52fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichettemplate <class T> 53fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichetclass Outmost { 54fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichetpublic: 55fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet template <class T> 56fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet class Inner { 57fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet public: 58fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet void f() { 59fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet T* var; 60fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet } 61fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet }; 62fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet}; 63fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet 64fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet} 65fdde47061d8ff0b481414ccf69ebdc47c2216274Francois Pichet 66d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 67d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichetnamespace PR11931 { 68d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 69d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichettemplate <typename RunType> 70d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichetstruct BindState; 71d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 72d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet template<> 73d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichetstruct BindState<void(void*)> { 74d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet static void Run() { } 75d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet}; 76d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 77d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichetclass Callback { 78d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichetpublic: 79d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet typedef void RunType(); 80d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 81d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet template <typename RunType> 82d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet Callback(BindState<RunType> bind_state) { 83d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet BindState<RunType>::Run(); 84d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet } 85d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet}; 86d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 87d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 88d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois PichetCallback Bind() { 89d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet return Callback(BindState<void(void*)>()); 90d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet} 91d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet 92d77177a752a08abf3f5cf46d7a3fe6143325815dFrancois Pichet} 93