2012-06-29 05:43:01 +08:00
|
|
|
// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify -std=c++11 %s
|
2011-04-25 14:34:35 +08:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class A {
|
|
|
|
void foo() {
|
|
|
|
undeclared();
|
|
|
|
}
|
2011-09-23 06:14:56 +08:00
|
|
|
void foo2();
|
2011-04-25 14:34:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class B {
|
2015-01-17 10:33:17 +08:00
|
|
|
void foo4() { } // expected-note {{previous definition is here}}
|
|
|
|
void foo4() { } // expected-error {{class member cannot be redeclared}}
|
2013-07-08 07:49:50 +08:00
|
|
|
void foo5() { } // expected-note {{previous definition is here}}
|
2011-11-19 07:47:17 +08:00
|
|
|
|
|
|
|
friend void foo3() {
|
|
|
|
undeclared();
|
|
|
|
}
|
2011-04-25 14:34:35 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
2013-07-08 07:49:50 +08:00
|
|
|
void B<T>::foo5() { // expected-error {{redefinition of 'foo5'}}
|
2011-04-25 14:34:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void A<T>::foo2() {
|
|
|
|
undeclared();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void foo3() {
|
|
|
|
undeclared();
|
|
|
|
}
|
|
|
|
|
|
|
|
template void A<int>::foo2();
|
|
|
|
|
|
|
|
|
|
|
|
void undeclared()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> void foo5() {} //expected-note {{previous definition is here}}
|
|
|
|
template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}}
|
2011-09-23 06:14:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-22 16:25:53 +08:00
|
|
|
|
|
|
|
namespace PR11931 {
|
|
|
|
|
|
|
|
template <typename RunType>
|
|
|
|
struct BindState;
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct BindState<void(void*)> {
|
|
|
|
static void Run() { }
|
|
|
|
};
|
|
|
|
|
|
|
|
class Callback {
|
|
|
|
public:
|
|
|
|
typedef void RunType();
|
|
|
|
|
|
|
|
template <typename RunType>
|
|
|
|
Callback(BindState<RunType> bind_state) {
|
|
|
|
BindState<RunType>::Run();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Callback Bind() {
|
|
|
|
return Callback(BindState<void(void*)>());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-06-29 05:43:01 +08:00
|
|
|
|
|
|
|
namespace rdar11700604 {
|
|
|
|
template<typename T> void foo() = delete;
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
X() = default;
|
|
|
|
|
|
|
|
template<typename T> void foo() = delete;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-09-27 12:14:12 +08:00
|
|
|
namespace PR17334 {
|
|
|
|
|
|
|
|
template <typename = void> struct ArrayRef {
|
|
|
|
constexpr ArrayRef() {}
|
|
|
|
};
|
|
|
|
template <typename = void> void CreateConstInBoundsGEP2_32() {
|
|
|
|
ArrayRef<> IdxList;
|
|
|
|
}
|
|
|
|
void LLVMBuildStructGEP() { CreateConstInBoundsGEP2_32(); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-24 05:31:20 +08:00
|
|
|
namespace PR17661 {
|
|
|
|
template <typename T>
|
|
|
|
constexpr T Fun(T A) { return T(0); }
|
|
|
|
|
|
|
|
constexpr int Var = Fun(20);
|
|
|
|
}
|
|
|
|
|
2014-03-13 07:14:33 +08:00
|
|
|
template <typename T>
|
|
|
|
auto invalidTrailingRetType() -> Bogus {} // expected-error {{unknown type name 'Bogus'}}
|
2014-05-02 10:01:07 +08:00
|
|
|
|
|
|
|
namespace PR19613 {
|
|
|
|
|
|
|
|
struct HeapTypeConfig {
|
|
|
|
static void from_bitset();
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Config>
|
|
|
|
struct TypeImpl {
|
|
|
|
struct BitsetType;
|
|
|
|
|
|
|
|
static void Any() {
|
|
|
|
BitsetType::New();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Config>
|
|
|
|
struct TypeImpl<Config>::BitsetType {
|
|
|
|
static void New() {
|
|
|
|
Config::from_bitset();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void f() {
|
|
|
|
TypeImpl<HeapTypeConfig>::Any();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename A> struct S {
|
|
|
|
template<typename B> struct T;
|
|
|
|
};
|
|
|
|
template<typename A> template<typename B> struct S<A>::T {
|
|
|
|
template<typename C, typename D> struct U;
|
|
|
|
template<typename C> struct U<C, C> {
|
|
|
|
template<typename E> static int f() {
|
|
|
|
return sizeof(A) + sizeof(B) + sizeof(C) + sizeof(E);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
static void g() {
|
|
|
|
S<int>::T<int>::U<int,int>::f<int>();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T> struct SS {
|
|
|
|
template<typename U> struct X;
|
|
|
|
template<typename U> struct X<U*>;
|
|
|
|
};
|
|
|
|
template<typename T> template<typename U> struct SS<T>::X<U*> {
|
|
|
|
static int f() {
|
|
|
|
return sizeof(T) + sizeof(U);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void h() {
|
|
|
|
SS<int>::X<int*>::f();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-11-28 05:20:42 +08:00
|
|
|
|
|
|
|
struct PR38460 {
|
|
|
|
template <typename>
|
|
|
|
struct T {
|
|
|
|
static void foo() {
|
|
|
|
struct U {
|
|
|
|
void dummy() {
|
|
|
|
use_delayed_identifier();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
void use_delayed_identifier();
|
|
|
|
void trigger_PR38460() {
|
|
|
|
PR38460::T<int>::foo();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename> struct PR38460_2 {
|
|
|
|
struct p {
|
|
|
|
struct G {
|
|
|
|
bool operator()(int) {}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
static void as() {
|
|
|
|
typename p::G g;
|
|
|
|
g(0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
template struct PR38460_2<int>;
|