1 // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s 3 4 // expected-no-diagnostics 5 class A { 6 public: 7 template<class U> A(U p) {} 8 template<> A(int p) {} 9 10 template<class U> void f(U p) {} 11 12 template<> void f(int p) {} 13 14 void f(int p) {} 15 }; 16 17 void test1() { 18 A a(3); 19 char *b; 20 a.f(b); 21 a.f<int>(99); 22 a.f(100); 23 } 24 25 template<class T> class B { 26 public: 27 template<class U> B(U p) {} 28 template<> B(int p) {} 29 30 template<class U> void f(U p) { T y = 9; } 31 32 template<> void f(int p) { 33 T a = 3; 34 } 35 36 void f(int p) { T a = 3; } 37 }; 38 39 void test2() { 40 B<char> b(3); 41 char *ptr; 42 b.f(ptr); 43 b.f<int>(99); 44 b.f(100); 45 } 46 47 namespace PR12709 { 48 template<class T> class TemplateClass { 49 void member_function() { specialized_member_template<false>(); } 50 51 template<bool b> void specialized_member_template() {} 52 53 template<> void specialized_member_template<false>() {} 54 }; 55 56 void f() { TemplateClass<int> t; } 57 } 58 59 namespace Duplicates { 60 template<typename T> struct A { 61 template<typename U> void f(); 62 template<> void f<int>() {} 63 template<> void f<T>() {} 64 }; 65 66 // FIXME: We should diagnose the duplicate explicit specialization definitions 67 // here. 68 template struct A<int>; 69 } 70 71 namespace PR28082 { 72 struct S { 73 template <int> 74 int f(int = 0); 75 template <> 76 int f<0>(int); 77 }; 78 } 79