• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
A(U p)6   template<class U> A(U p) {}
A(int p)7   template<> A(int p) {
8     // expected-warning@-1 {{explicit specialization of 'A' within class scope is a Microsoft extension}}
9   }
10 
f(U p)11   template<class U> void f(U p) {}
12 
f(int p)13   template<> void f(int p) {
14     // expected-warning@-1 {{explicit specialization of 'f' within class scope is a Microsoft extension}}
15   }
16 
f(int p)17   void f(int p) {}
18 };
19 
test1()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:
B(U p)30   template<class U> B(U p) {}
B(int p)31   template<> B(int p) {
32     // expected-warning@-1 {{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
33   }
34 
f(U p)35   template<class U> void f(U p) { T y = 9; }
36 
f(int p)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 
f(int p)42   void f(int p) { T a = 3; }
43 };
44 
test2()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 {
member_function()55     void member_function() { specialized_member_template<false>(); }
56 
specialized_member_template()57     template<bool b> void specialized_member_template() {}
58 
specialized_member_template()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 
f()64   void f() { TemplateClass<int> t; }
65 }
66 
67 namespace Duplicates {
68   template<typename T> struct A {
69     template<typename U> void f();
fDuplicates::A70     template<> void f<int>() {} // expected-warning {{Microsoft extension}}
fDuplicates::A71     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 
79 namespace PR28082 {
80 struct S {
81   template <int>
82   int f(int = 0);
83   template <>
84   int f<0>(int); // expected-warning {{Microsoft extension}}
85 };
86 }
87