blob: b2d05234106e3be9bb2eaecf5a86fc7d09ab5916 [file] [log] [blame]
Sebastian Redl5967d622010-08-24 00:50:16 +00001// Test C++ chained PCH functionality
2
3// Without PCH
Andrew Trick220a9c82010-10-19 21:54:32 +00004// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
Sebastian Redl5967d622010-08-24 00:50:16 +00005
6// With PCH
Andrew Trick220a9c82010-10-19 21:54:32 +00007// 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 Redl5967d622010-08-24 00:50:16 +00009// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
10
Andrew Trick220a9c82010-10-19 21:54:32 +000011#ifndef HEADER1
12#define HEADER1
13//===----------------------------------------------------------------------===//
14// Primary header for C++ chained PCH test
15
16void f();
17
18// Name not appearing in dependent
19void pf();
20
21namespace ns {
22 void g();
23
24 void pg();
25}
26
27template <typename T>
28struct S { typedef int G; };
29
30// Partially specialize
31template <typename T>
32struct S<T *> { typedef int H; };
33
34//===----------------------------------------------------------------------===//
35#elif not defined(HEADER2)
36#define HEADER2
37//===----------------------------------------------------------------------===//
38// Dependent header for C++ chained PCH test
39
40// Overload function from primary
41void f(int);
42
43// Add function with different name
44void f2();
45
46// Reopen namespace
47namespace ns {
48 // Overload function from primary
49 void g(int);
50
51 // Add different name
52 void g2();
53}
54
55// Specialize template from primary
56template <>
57struct S<int> { typedef int I; };
58
59// Partially specialize
60template <typename T>
61struct S<T &> { typedef int J; };
62
63// Specialize previous partial specialization
64template <>
65struct S<int *> { typedef int K; };
66
67// Specialize the partial specialization from this file
68template <>
69struct S<int &> { typedef int L; };
70
71//===----------------------------------------------------------------------===//
72#else
73//===----------------------------------------------------------------------===//
74
Sebastian Redl5967d622010-08-24 00:50:16 +000075void test() {
76 f();
77 f(1);
78 pf();
79 f2();
80
81 ns::g();
82 ns::g(1);
83 ns::pg();
84 ns::g2();
85
Sebastian Redl4153a062010-08-24 22:50:24 +000086 typedef S<double>::G T1;
87 typedef S<double *>::H T2;
88 typedef S<int>::I T3;
89 typedef S<double &>::J T4;
90 typedef S<int *>::K T5;
91 typedef S<int &>::L T6;
Sebastian Redl5967d622010-08-24 00:50:16 +000092}
Andrew Trick220a9c82010-10-19 21:54:32 +000093
94//===----------------------------------------------------------------------===//
95#endif