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