blob: bf37acb298e56e7a0b1bc4cc406cdd6445ac4968 [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
Anders Carlssonf25330b2011-03-09 05:09:32 +000037template <typename T> struct TestBaseSpecifiers { };
38template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
39
Andrew Trick220a9c82010-10-19 21:54:32 +000040//===----------------------------------------------------------------------===//
41#elif not defined(HEADER2)
42#define HEADER2
43//===----------------------------------------------------------------------===//
44// Dependent header for C++ chained PCH test
45
46// Overload function from primary
47void f(int);
48
49// Add function with different name
50void f2();
51
52// Reopen namespace
53namespace ns {
54 // Overload function from primary
55 void g(int);
56
57 // Add different name
58 void g2();
59}
60
61// Specialize template from primary
62template <>
63struct S<int> { typedef int I; };
64
65// Partially specialize
66template <typename T>
67struct S<T &> { typedef int J; };
68
69// Specialize previous partial specialization
70template <>
71struct S<int *> { typedef int K; };
72
73// Specialize the partial specialization from this file
74template <>
75struct S<int &> { typedef int L; };
76
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +000077template <typename T> struct TS2 { };
78
Anders Carlssonf25330b2011-03-09 05:09:32 +000079struct TestBaseSpecifiers3 { };
80struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
81
Anders Carlssonc8505782011-03-06 18:41:18 +000082struct A { };
83struct B : A { };
84
Andrew Trick220a9c82010-10-19 21:54:32 +000085//===----------------------------------------------------------------------===//
86#else
87//===----------------------------------------------------------------------===//
88
Sebastian Redl5967d622010-08-24 00:50:16 +000089void test() {
90 f();
91 f(1);
92 pf();
93 f2();
94
95 ns::g();
96 ns::g(1);
97 ns::pg();
98 ns::g2();
99
Sebastian Redl4153a062010-08-24 22:50:24 +0000100 typedef S<double>::G T1;
101 typedef S<double *>::H T2;
102 typedef S<int>::I T3;
103 typedef S<double &>::J T4;
104 typedef S<int *>::K T5;
105 typedef S<int &>::L T6;
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +0000106
107 TS2int ts2;
Anders Carlssonc8505782011-03-06 18:41:18 +0000108
109 B b;
Sebastian Redl5967d622010-08-24 00:50:16 +0000110}
Andrew Trick220a9c82010-10-19 21:54:32 +0000111
112//===----------------------------------------------------------------------===//
113#endif