Sebastian Redl | 5967d62 | 2010-08-24 00:50:16 +0000 | [diff] [blame] | 1 | // Test C++ chained PCH functionality |
| 2 | |
| 3 | // Without PCH |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s |
Sebastian Redl | 5967d62 | 2010-08-24 00:50:16 +0000 | [diff] [blame] | 5 | |
| 6 | // With PCH |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 7 | // RUN: %clang_cc1 -x c++-header -emit-pch -o %t1 %s |
| 8 | // RUN: %clang_cc1 -x c++-header -emit-pch -o %t2 %s -include-pch %t1 -chained-pch |
Sebastian Redl | 5967d62 | 2010-08-24 00:50:16 +0000 | [diff] [blame] | 9 | // RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s |
| 10 | |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 11 | #ifndef HEADER1 |
| 12 | #define HEADER1 |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | // Primary header for C++ chained PCH test |
| 15 | |
| 16 | void f(); |
| 17 | |
| 18 | // Name not appearing in dependent |
| 19 | void pf(); |
| 20 | |
| 21 | namespace ns { |
| 22 | void g(); |
| 23 | |
| 24 | void pg(); |
| 25 | } |
| 26 | |
| 27 | template <typename T> |
| 28 | struct S { typedef int G; }; |
| 29 | |
| 30 | // Partially specialize |
| 31 | template <typename T> |
| 32 | struct S<T *> { typedef int H; }; |
| 33 | |
Argyrios Kyrtzidis | 9703b0d | 2010-10-20 00:11:15 +0000 | [diff] [blame] | 34 | template <typename T> struct TS2; |
| 35 | typedef TS2<int> TS2int; |
| 36 | |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 37 | //===----------------------------------------------------------------------===// |
| 38 | #elif not defined(HEADER2) |
| 39 | #define HEADER2 |
| 40 | //===----------------------------------------------------------------------===// |
| 41 | // Dependent header for C++ chained PCH test |
| 42 | |
| 43 | // Overload function from primary |
| 44 | void f(int); |
| 45 | |
| 46 | // Add function with different name |
| 47 | void f2(); |
| 48 | |
| 49 | // Reopen namespace |
| 50 | namespace ns { |
| 51 | // Overload function from primary |
| 52 | void g(int); |
| 53 | |
| 54 | // Add different name |
| 55 | void g2(); |
| 56 | } |
| 57 | |
| 58 | // Specialize template from primary |
| 59 | template <> |
| 60 | struct S<int> { typedef int I; }; |
| 61 | |
| 62 | // Partially specialize |
| 63 | template <typename T> |
| 64 | struct S<T &> { typedef int J; }; |
| 65 | |
| 66 | // Specialize previous partial specialization |
| 67 | template <> |
| 68 | struct S<int *> { typedef int K; }; |
| 69 | |
| 70 | // Specialize the partial specialization from this file |
| 71 | template <> |
| 72 | struct S<int &> { typedef int L; }; |
| 73 | |
Argyrios Kyrtzidis | 9703b0d | 2010-10-20 00:11:15 +0000 | [diff] [blame] | 74 | template <typename T> struct TS2 { }; |
| 75 | |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 76 | //===----------------------------------------------------------------------===// |
| 77 | #else |
| 78 | //===----------------------------------------------------------------------===// |
| 79 | |
Sebastian Redl | 5967d62 | 2010-08-24 00:50:16 +0000 | [diff] [blame] | 80 | void test() { |
| 81 | f(); |
| 82 | f(1); |
| 83 | pf(); |
| 84 | f2(); |
| 85 | |
| 86 | ns::g(); |
| 87 | ns::g(1); |
| 88 | ns::pg(); |
| 89 | ns::g2(); |
| 90 | |
Sebastian Redl | 4153a06 | 2010-08-24 22:50:24 +0000 | [diff] [blame] | 91 | typedef S<double>::G T1; |
| 92 | typedef S<double *>::H T2; |
| 93 | typedef S<int>::I T3; |
| 94 | typedef S<double &>::J T4; |
| 95 | typedef S<int *>::K T5; |
| 96 | typedef S<int &>::L T6; |
Argyrios Kyrtzidis | 9703b0d | 2010-10-20 00:11:15 +0000 | [diff] [blame] | 97 | |
| 98 | TS2int ts2; |
Sebastian Redl | 5967d62 | 2010-08-24 00:50:16 +0000 | [diff] [blame] | 99 | } |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 100 | |
| 101 | //===----------------------------------------------------------------------===// |
| 102 | #endif |