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
|
|
|
|
2018-03-16 21:36:56 +08:00
|
|
|
// expected-no-diagnostics
|
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) {}
|
2018-03-16 21:36:56 +08:00
|
|
|
template<> A(int p) {}
|
2011-08-14 11:52:19 +08:00
|
|
|
|
2013-12-14 06:26:20 +08:00
|
|
|
template<class U> void f(U p) {}
|
|
|
|
|
2018-03-16 21:36:56 +08:00
|
|
|
template<> void f(int p) {}
|
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) {}
|
2018-03-16 21:36:56 +08:00
|
|
|
template<> B(int p) {}
|
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) {
|
|
|
|
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
|
|
|
|
2018-03-16 21:36:56 +08:00
|
|
|
template<> void specialized_member_template<false>() {}
|
2013-12-14 06:28:48 +08:00
|
|
|
};
|
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();
|
2018-03-16 21:36:56 +08:00
|
|
|
template<> void f<int>() {}
|
|
|
|
template<> void f<T>() {}
|
2013-12-14 06:28:48 +08:00
|
|
|
};
|
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
|
|
|
}
|
2016-06-11 04:21:15 +08:00
|
|
|
|
|
|
|
namespace PR28082 {
|
|
|
|
struct S {
|
|
|
|
template <int>
|
|
|
|
int f(int = 0);
|
|
|
|
template <>
|
2018-03-16 21:36:56 +08:00
|
|
|
int f<0>(int);
|
2016-06-11 04:21:15 +08:00
|
|
|
};
|
|
|
|
}
|