blob: d269de529fba3a4d6ff1a85af2c1bee5e95c9b96 [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
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +000034template <typename T> struct TS2;
35typedef TS2<int> TS2int;
36
Andrew Trick220a9c82010-10-19 21:54:32 +000037//===----------------------------------------------------------------------===//
38#elif not defined(HEADER2)
39#define HEADER2
40//===----------------------------------------------------------------------===//
41// Dependent header for C++ chained PCH test
42
43// Overload function from primary
44void f(int);
45
46// Add function with different name
47void f2();
48
49// Reopen namespace
50namespace 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
59template <>
60struct S<int> { typedef int I; };
61
62// Partially specialize
63template <typename T>
64struct S<T &> { typedef int J; };
65
66// Specialize previous partial specialization
67template <>
68struct S<int *> { typedef int K; };
69
70// Specialize the partial specialization from this file
71template <>
72struct S<int &> { typedef int L; };
73
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +000074template <typename T> struct TS2 { };
75
Andrew Trick220a9c82010-10-19 21:54:32 +000076//===----------------------------------------------------------------------===//
77#else
78//===----------------------------------------------------------------------===//
79
Sebastian Redl5967d622010-08-24 00:50:16 +000080void 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 Redl4153a062010-08-24 22:50:24 +000091 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 Kyrtzidis9703b0d2010-10-20 00:11:15 +000097
98 TS2int ts2;
Sebastian Redl5967d622010-08-24 00:50:16 +000099}
Andrew Trick220a9c82010-10-19 21:54:32 +0000100
101//===----------------------------------------------------------------------===//
102#endif