2010-06-23 21:48:30 +08:00
|
|
|
// Test this without pch.
|
2011-02-28 08:40:07 +08:00
|
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o -
|
|
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s
|
2010-06-20 03:28:53 +08:00
|
|
|
|
2010-06-23 21:48:30 +08:00
|
|
|
// Test with pch.
|
2011-02-28 08:40:07 +08:00
|
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h
|
|
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o -
|
|
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s
|
2010-08-04 01:30:10 +08:00
|
|
|
|
2010-08-05 17:48:16 +08:00
|
|
|
// CHECK: define weak_odr void @_ZN2S4IiE1mEv
|
2010-08-04 01:30:10 +08:00
|
|
|
// CHECK: define linkonce_odr void @_ZN2S3IiE1mEv
|
2010-06-24 16:57:31 +08:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
typedef int type;
|
|
|
|
static void my_f();
|
|
|
|
template <typename T>
|
|
|
|
static T my_templf(T x) { return x; }
|
|
|
|
};
|
2010-06-22 17:55:07 +08:00
|
|
|
|
2010-10-26 08:51:02 +08:00
|
|
|
void test(const int (&a6)[17]) {
|
2010-06-26 00:25:09 +08:00
|
|
|
int x = templ_f<int, 5>(3);
|
2010-06-23 21:48:30 +08:00
|
|
|
|
|
|
|
S<char, float>::templ();
|
|
|
|
S<int, char>::partial();
|
|
|
|
S<int, float>::explicit_special();
|
2010-06-24 16:57:31 +08:00
|
|
|
|
|
|
|
Dep<A>::Ty ty;
|
|
|
|
Dep<A> a;
|
|
|
|
a.f();
|
2010-08-04 01:30:10 +08:00
|
|
|
|
|
|
|
S3<int> s3;
|
|
|
|
s3.m();
|
2010-09-07 03:04:27 +08:00
|
|
|
|
|
|
|
TS5 ts(0);
|
2010-10-26 08:51:02 +08:00
|
|
|
|
|
|
|
S6<const int[17]>::t2 b6 = a6;
|
2010-06-22 17:55:07 +08:00
|
|
|
}
|
2010-08-05 17:48:16 +08:00
|
|
|
|
|
|
|
template struct S4<int>;
|
2010-10-30 06:39:52 +08:00
|
|
|
|
|
|
|
S7<int[5]> s7_5;
|
2011-02-04 20:01:24 +08:00
|
|
|
|
|
|
|
namespace ZeroLengthExplicitTemplateArgs {
|
|
|
|
template void f<X>(X*);
|
|
|
|
}
|
2011-03-07 02:19:42 +08:00
|
|
|
|
|
|
|
// This used to overwrite memory and crash.
|
|
|
|
namespace Test1 {
|
|
|
|
struct StringHasher {
|
|
|
|
template<typename T, char Converter(T)> static inline unsigned createHash(const T*, unsigned) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CaseFoldingHash {
|
|
|
|
static inline char foldCase(char) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned hash(const char* data, unsigned length) {
|
|
|
|
return StringHasher::createHash<char, foldCase>(data, length);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2012-03-26 23:52:37 +08:00
|
|
|
|
|
|
|
template< typename D >
|
|
|
|
Foo< D >& Foo< D >::operator=( const Foo& other )
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|