2010-06-23 21:48:30 +08:00
|
|
|
// Test this without pch.
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o -
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s
|
2010-06-20 03:28:53 +08:00
|
|
|
|
2010-06-23 21:48:30 +08:00
|
|
|
// Test with pch.
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o -
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize -DNO_ERRORS | FileCheck %s
|
2010-08-04 01:30:10 +08:00
|
|
|
|
2013-06-28 12:37:53 +08:00
|
|
|
// Test with modules.
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fmodules -x c++-header -emit-pch -o %t %S/cxx-templates.h
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fmodules -include-pch %t -verify %s -ast-dump -o -
|
2015-02-20 04:12:20 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions -fmodules -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize -DNO_ERRORS -fmodules-ignore-macro=NO_ERRORS | FileCheck %s
|
2013-06-28 12:37:53 +08:00
|
|
|
|
2013-08-08 05:41:30 +08:00
|
|
|
// Test with pch and delayed template parsing.
|
2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fdelayed-template-parsing -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t -verify %s -ast-dump -o -
|
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s
|
2012-10-19 20:44:48 +08:00
|
|
|
|
2013-12-13 00:07:11 +08:00
|
|
|
// CHECK: define weak_odr {{.*}}void @_ZN2S4IiE1mEv
|
|
|
|
// 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;
|
|
|
|
}
|
2012-09-12 08:56:43 +08:00
|
|
|
|
|
|
|
namespace TestNestedExpansion {
|
|
|
|
struct Int {
|
|
|
|
Int(int);
|
|
|
|
friend Int operator+(Int, Int);
|
|
|
|
};
|
|
|
|
Int &g(Int, int, double);
|
|
|
|
Int &test = NestedExpansion<char, char, char>().f(0, 1, 2, Int(3), 4, 5.0);
|
|
|
|
}
|
2013-02-16 08:48:59 +08:00
|
|
|
|
|
|
|
namespace rdar13135282 {
|
|
|
|
void test() {
|
|
|
|
__mt_alloc<> mt = __mt_alloc<>();
|
|
|
|
}
|
|
|
|
}
|
2013-06-19 09:38:21 +08:00
|
|
|
|
|
|
|
void CallDependentSpecializedFunc(DependentSpecializedFuncClass<int> &x) {
|
|
|
|
DependentSpecializedFunc(x);
|
|
|
|
}
|
2013-07-13 10:00:19 +08:00
|
|
|
|
|
|
|
namespace cyclic_module_load {
|
|
|
|
extern std::valarray<int> x;
|
|
|
|
std::valarray<int> y(x);
|
|
|
|
}
|
2013-08-14 02:18:50 +08:00
|
|
|
|
|
|
|
#ifndef NO_ERRORS
|
|
|
|
// expected-error@cxx-templates.h:305 {{incomplete}}
|
|
|
|
template int local_extern::f<int[]>(); // expected-note {{in instantiation of}}
|
|
|
|
#endif
|
|
|
|
template int local_extern::g<int[]>();
|
2017-05-10 07:02:10 +08:00
|
|
|
|
|
|
|
namespace MemberSpecializationLocation {
|
|
|
|
#ifndef NO_ERRORS
|
|
|
|
// expected-note@cxx-templates.h:* {{previous}}
|
|
|
|
template<> float A<int>::n; // expected-error {{redeclaration of 'n' with a different type}}
|
|
|
|
#endif
|
|
|
|
int k = A<int>::n;
|
|
|
|
}
|