blob: 9efb02ce5f515a5668b322a73995a48eabfa4813 [file] [log] [blame]
Francois Pichetaf0f4d02011-08-14 03:52:19 +00001// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
Richard Smithfed844d2013-04-29 08:53:40 +00002// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s
Francois Pichetaf0f4d02011-08-14 03:52:19 +00003
4
5class A {
6public:
7 template <class U>
8 A(U p) {
9 }
10 template <>
Francois Pichet2fd9a472011-08-14 22:30:29 +000011 A(int p) { // expected-warning{{explicit specialization of 'A' within class scope is a Microsoft extension}}
Francois Pichetaf0f4d02011-08-14 03:52:19 +000012 }
13
14 template <class U>
15 void f(U p) {
16 }
17
18 template <>
Francois Pichet2fd9a472011-08-14 22:30:29 +000019 void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
Francois Pichetaf0f4d02011-08-14 03:52:19 +000020 }
21
22 void f(int p) {
23 }
24};
25
26void 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
38template <class T>
39class B {
40public:
41 template <class U>
42 B(U p) {
43 }
44 template <>
Francois Pichet2fd9a472011-08-14 22:30:29 +000045 B(int p) { // expected-warning{{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
Francois Pichetaf0f4d02011-08-14 03:52:19 +000046 }
47
48 template <class U>
49 void f(U p) {
50 T y = 9;
51 }
52
53
54 template <>
Francois Pichet2fd9a472011-08-14 22:30:29 +000055 void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
Francois Pichetaf0f4d02011-08-14 03:52:19 +000056 T a = 3;
57 }
58
59 void f(int p) {
60 T a = 3;
61 }
62};
63
64void 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
Nico Weber6b020092012-06-25 17:21:05 +000073
74namespace PR12709 {
75
76template<class T>
77class 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
89void f() {
90 TemplateClass<int> t;
91}
92
93}