blob: 7ce247721f8f0b7d2124344252566fa43bc8d5a1 [file] [log] [blame]
Argyrios Kyrtzidis818c5db2010-06-23 13:48:30 +00001// Test this without pch.
Anders Carlsson6774b1f2011-02-28 00:40:07 +00002// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o -
3// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s
Argyrios Kyrtzidis106caf922010-06-19 19:28:53 +00004
Argyrios Kyrtzidis818c5db2010-06-23 13:48:30 +00005// Test with pch.
Anders Carlsson6774b1f2011-02-28 00:40:07 +00006// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h
7// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o -
8// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s
Argyrios Kyrtzidis839bbac2010-08-03 17:30:10 +00009
Argyrios Kyrtzidis7f76d112010-08-05 09:48:16 +000010// CHECK: define weak_odr void @_ZN2S4IiE1mEv
Argyrios Kyrtzidis839bbac2010-08-03 17:30:10 +000011// CHECK: define linkonce_odr void @_ZN2S3IiE1mEv
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +000012
13struct A {
14 typedef int type;
15 static void my_f();
16 template <typename T>
17 static T my_templf(T x) { return x; }
18};
Argyrios Kyrtzidis69da4a82010-06-22 09:55:07 +000019
Douglas Gregorf86c9392010-10-26 00:51:02 +000020void test(const int (&a6)[17]) {
Argyrios Kyrtzidisb1d38e32010-06-25 16:25:09 +000021 int x = templ_f<int, 5>(3);
Argyrios Kyrtzidis818c5db2010-06-23 13:48:30 +000022
23 S<char, float>::templ();
24 S<int, char>::partial();
25 S<int, float>::explicit_special();
Argyrios Kyrtzidisbfcacee2010-06-24 08:57:31 +000026
27 Dep<A>::Ty ty;
28 Dep<A> a;
29 a.f();
Argyrios Kyrtzidis839bbac2010-08-03 17:30:10 +000030
31 S3<int> s3;
32 s3.m();
Argyrios Kyrtzidisd05f3e32010-09-06 19:04:27 +000033
34 TS5 ts(0);
Douglas Gregorf86c9392010-10-26 00:51:02 +000035
36 S6<const int[17]>::t2 b6 = a6;
Argyrios Kyrtzidis69da4a82010-06-22 09:55:07 +000037}
Argyrios Kyrtzidis7f76d112010-08-05 09:48:16 +000038
39template struct S4<int>;
Douglas Gregord4c5ed02010-10-29 22:39:52 +000040
41S7<int[5]> s7_5;
Douglas Gregor87866ce2011-02-04 12:01:24 +000042
43namespace ZeroLengthExplicitTemplateArgs {
44 template void f<X>(X*);
45}
Anders Carlsson80756f62011-03-06 18:19:42 +000046
47// This used to overwrite memory and crash.
48namespace Test1 {
49 struct StringHasher {
50 template<typename T, char Converter(T)> static inline unsigned createHash(const T*, unsigned) {
51 return 0;
52 }
53 };
54
55 struct CaseFoldingHash {
56 static inline char foldCase(char) {
57 return 0;
58 }
59
60 static unsigned hash(const char* data, unsigned length) {
61 return StringHasher::createHash<char, foldCase>(data, length);
62 }
63 };
64}
Douglas Gregor9f218892012-03-26 15:52:37 +000065
66template< typename D >
67Foo< D >& Foo< D >::operator=( const Foo& other )
68{
69 return *this;
70}