Home | History | Annotate | Download | only in SemaTemplate
      1 // RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
      2 
      3 
      4 class A {
      5 public:
      6 	template <class U>
      7     A(U p) {
      8 	}
      9 	template <>
     10     A(int p) { // expected-warning{{explicit specialization of 'A' within class scope is a Microsoft extension}}
     11 	}
     12 
     13 	template <class U>
     14     void f(U p) {
     15 	}
     16 
     17 	template <>
     18     void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
     19 	}
     20 
     21 	void f(int p) {
     22     }
     23 };
     24 
     25 void test1()
     26 {
     27    A a(3);
     28    char* b ;
     29    a.f(b);
     30    a.f<int>(99);
     31    a.f(100);
     32 }
     33 
     34 
     35 
     36 
     37 template <class T>
     38 class B {
     39 public:
     40 	template <class U>
     41     B(U p) {
     42 	}
     43 	template <>
     44     B(int p) { // expected-warning{{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
     45 	}
     46 
     47 	template <class U>
     48     void f(U p) {
     49 	  T y = 9;
     50 	}
     51 
     52 
     53     template <>
     54     void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
     55 	  T a = 3;
     56 	}
     57 
     58 	void f(int p) {
     59  	  T a = 3;
     60     }
     61 };
     62 
     63 void test2()
     64 {
     65    B<char> b(3);
     66    char* ptr;
     67    b.f(ptr);
     68    b.f<int>(99);
     69    b.f(100);
     70 }
     71 
     72 
     73 namespace PR12709 {
     74 
     75 template<class T>
     76 class TemplateClass {
     77   void member_function() {
     78     specialized_member_template<false>();
     79   }
     80 
     81   template<bool b>
     82   void specialized_member_template() {}
     83 
     84   template<>
     85   void specialized_member_template<false>() {}  // expected-warning{{explicit specialization of 'specialized_member_template' within class scope is a Microsoft extension}}
     86 };
     87 
     88 void f() {
     89   TemplateClass<int> t;
     90 }
     91 
     92 }
     93