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