| Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 1 | // Test this without pch. | 
| Richard Smith | b15fe3a | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o - | 
|  | 3 | // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s | 
| Argyrios Kyrtzidis | 106caf92 | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 4 |  | 
| Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 5 | // Test with pch. | 
| Richard Smith | b15fe3a | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 6 | // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h | 
|  | 7 | // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump  -o - | 
|  | 8 | // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s | 
| Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 9 |  | 
| Andy Gibbs | c6e68da | 2012-10-19 12:44:48 +0000 | [diff] [blame] | 10 | // expected-no-diagnostics | 
|  | 11 |  | 
| Argyrios Kyrtzidis | 7f76d11 | 2010-08-05 09:48:16 +0000 | [diff] [blame] | 12 | // CHECK: define weak_odr void @_ZN2S4IiE1mEv | 
| Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 13 | // CHECK: define linkonce_odr void @_ZN2S3IiE1mEv | 
| Argyrios Kyrtzidis | bfcacee | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 14 |  | 
|  | 15 | struct A { | 
|  | 16 | typedef int type; | 
|  | 17 | static void my_f(); | 
|  | 18 | template <typename T> | 
|  | 19 | static T my_templf(T x) { return x; } | 
|  | 20 | }; | 
| Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 21 |  | 
| Douglas Gregor | f86c939 | 2010-10-26 00:51:02 +0000 | [diff] [blame] | 22 | void test(const int (&a6)[17]) { | 
| Argyrios Kyrtzidis | b1d38e3 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 23 | int x = templ_f<int, 5>(3); | 
| Argyrios Kyrtzidis | 818c5db | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 24 |  | 
|  | 25 | S<char, float>::templ(); | 
|  | 26 | S<int, char>::partial(); | 
|  | 27 | S<int, float>::explicit_special(); | 
| Argyrios Kyrtzidis | bfcacee | 2010-06-24 08:57:31 +0000 | [diff] [blame] | 28 |  | 
|  | 29 | Dep<A>::Ty ty; | 
|  | 30 | Dep<A> a; | 
|  | 31 | a.f(); | 
| Argyrios Kyrtzidis | 839bbac | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 32 |  | 
|  | 33 | S3<int> s3; | 
|  | 34 | s3.m(); | 
| Argyrios Kyrtzidis | d05f3e3 | 2010-09-06 19:04:27 +0000 | [diff] [blame] | 35 |  | 
|  | 36 | TS5 ts(0); | 
| Douglas Gregor | f86c939 | 2010-10-26 00:51:02 +0000 | [diff] [blame] | 37 |  | 
|  | 38 | S6<const int[17]>::t2 b6 = a6; | 
| Argyrios Kyrtzidis | 69da4a8 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 39 | } | 
| Argyrios Kyrtzidis | 7f76d11 | 2010-08-05 09:48:16 +0000 | [diff] [blame] | 40 |  | 
|  | 41 | template struct S4<int>; | 
| Douglas Gregor | d4c5ed0 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 42 |  | 
|  | 43 | S7<int[5]> s7_5; | 
| Douglas Gregor | 87866ce | 2011-02-04 12:01:24 +0000 | [diff] [blame] | 44 |  | 
|  | 45 | namespace ZeroLengthExplicitTemplateArgs { | 
|  | 46 | template void f<X>(X*); | 
|  | 47 | } | 
| Anders Carlsson | 80756f6 | 2011-03-06 18:19:42 +0000 | [diff] [blame] | 48 |  | 
|  | 49 | // This used to overwrite memory and crash. | 
|  | 50 | namespace Test1 { | 
|  | 51 | struct StringHasher { | 
|  | 52 | template<typename T, char Converter(T)> static inline unsigned createHash(const T*, unsigned) { | 
|  | 53 | return 0; | 
|  | 54 | } | 
|  | 55 | }; | 
|  | 56 |  | 
|  | 57 | struct CaseFoldingHash { | 
|  | 58 | static inline char foldCase(char) { | 
|  | 59 | return 0; | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | static unsigned hash(const char* data, unsigned length) { | 
|  | 63 | return StringHasher::createHash<char, foldCase>(data, length); | 
|  | 64 | } | 
|  | 65 | }; | 
|  | 66 | } | 
| Douglas Gregor | 9f21889 | 2012-03-26 15:52:37 +0000 | [diff] [blame] | 67 |  | 
|  | 68 | template< typename D > | 
|  | 69 | Foo< D >& Foo< D >::operator=( const Foo& other ) | 
|  | 70 | { | 
|  | 71 | return *this; | 
|  | 72 | } | 
| Richard Smith | b15fe3a | 2012-09-12 00:56:43 +0000 | [diff] [blame] | 73 |  | 
|  | 74 | namespace TestNestedExpansion { | 
|  | 75 | struct Int { | 
|  | 76 | Int(int); | 
|  | 77 | friend Int operator+(Int, Int); | 
|  | 78 | }; | 
|  | 79 | Int &g(Int, int, double); | 
|  | 80 | Int &test = NestedExpansion<char, char, char>().f(0, 1, 2, Int(3), 4, 5.0); | 
|  | 81 | } | 
| Argyrios Kyrtzidis | 83a6e3b | 2013-02-16 00:48:59 +0000 | [diff] [blame] | 82 |  | 
|  | 83 | namespace rdar13135282 { | 
|  | 84 | void test() { | 
|  | 85 | __mt_alloc<> mt = __mt_alloc<>(); | 
|  | 86 | } | 
|  | 87 | } |