2011-08-14 11:52:19 +08:00
|
|
|
// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
|
2013-04-29 16:53:40 +08:00
|
|
|
// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s
|
2011-08-14 11:52:19 +08:00
|
|
|
|
|
|
|
class A {
|
|
|
|
public:
|
2013-12-14 06:26:20 +08:00
|
|
|
template<class U> A(U p) {}
|
|
|
|
template<> A(int p) {
|
|
|
|
// expected-warning@-1 {{explicit specialization of 'A' within class scope is a Microsoft extension}}
|
|
|
|
}
|
2011-08-14 11:52:19 +08:00
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
template<class U> void f(U p) {}
|
|
|
|
|
|
|
|
template<> void f(int p) {
|
|
|
|
// expected-warning@-1 {{explicit specialization of 'f' within class scope is a Microsoft extension}}
|
|
|
|
}
|
2011-08-14 11:52:19 +08:00
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
void f(int p) {}
|
2011-08-14 11:52:19 +08:00
|
|
|
};
|
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
void test1() {
|
|
|
|
A a(3);
|
|
|
|
char *b;
|
|
|
|
a.f(b);
|
|
|
|
a.f<int>(99);
|
|
|
|
a.f(100);
|
2011-08-14 11:52:19 +08:00
|
|
|
}
|
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
template<class T> class B {
|
2011-08-14 11:52:19 +08:00
|
|
|
public:
|
2013-12-14 06:26:20 +08:00
|
|
|
template<class U> B(U p) {}
|
|
|
|
template<> B(int p) {
|
|
|
|
// expected-warning@-1 {{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
|
|
|
|
}
|
2011-08-14 11:52:19 +08:00
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
template<class U> void f(U p) { T y = 9; }
|
2011-08-14 11:52:19 +08:00
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
template<> void f(int p) {
|
|
|
|
// expected-warning@-1 {{explicit specialization of 'f' within class scope is a Microsoft extension}}
|
|
|
|
T a = 3;
|
|
|
|
}
|
2011-08-14 11:52:19 +08:00
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
void f(int p) { T a = 3; }
|
2011-08-14 11:52:19 +08:00
|
|
|
};
|
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
void test2() {
|
|
|
|
B<char> b(3);
|
|
|
|
char *ptr;
|
|
|
|
b.f(ptr);
|
|
|
|
b.f<int>(99);
|
|
|
|
b.f(100);
|
2011-08-14 11:52:19 +08:00
|
|
|
}
|
|
|
|
|
2012-06-26 01:21:05 +08:00
|
|
|
namespace PR12709 {
|
2013-12-14 06:28:48 +08:00
|
|
|
template<class T> class TemplateClass {
|
|
|
|
void member_function() { specialized_member_template<false>(); }
|
2012-06-26 01:21:05 +08:00
|
|
|
|
2013-12-14 06:28:48 +08:00
|
|
|
template<bool b> void specialized_member_template() {}
|
2012-06-26 01:21:05 +08:00
|
|
|
|
2013-12-14 06:28:48 +08:00
|
|
|
template<> void specialized_member_template<false>() {
|
|
|
|
// expected-warning@-1 {{explicit specialization of 'specialized_member_template' within class scope is a Microsoft extension}}
|
|
|
|
}
|
|
|
|
};
|
2012-06-26 01:21:05 +08:00
|
|
|
|
2013-12-14 06:28:48 +08:00
|
|
|
void f() { TemplateClass<int> t; }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Duplicates {
|
|
|
|
template<typename T> struct A {
|
|
|
|
template<typename U> void f();
|
|
|
|
template<> void f<int>() {} // expected-warning {{Microsoft extension}}
|
|
|
|
template<> void f<T>() {} // expected-warning {{Microsoft extension}}
|
|
|
|
};
|
2012-06-26 01:21:05 +08:00
|
|
|
|
2013-12-14 06:28:48 +08:00
|
|
|
// FIXME: We should diagnose the duplicate explicit specialization definitions
|
|
|
|
// here.
|
|
|
|
template struct A<int>;
|
2012-06-26 01:21:05 +08:00
|
|
|
}
|