blob: 107ddfee1c0d0a7009d90734af4065fb144939f7 [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
Argyrios Kyrtzidisb0f4b9a2011-03-09 17:21:42 +00007// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
Sebastian Redl5967d622010-08-24 00:50:16 +00008
Andrew Trick220a9c82010-10-19 21:54:32 +00009#ifndef HEADER1
10#define HEADER1
11//===----------------------------------------------------------------------===//
12// Primary header for C++ chained PCH test
13
14void f();
15
16// Name not appearing in dependent
17void pf();
18
19namespace ns {
20 void g();
21
22 void pg();
23}
24
25template <typename T>
26struct S { typedef int G; };
27
28// Partially specialize
29template <typename T>
30struct S<T *> { typedef int H; };
31
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +000032template <typename T> struct TS2;
33typedef TS2<int> TS2int;
34
Anders Carlssonf25330b2011-03-09 05:09:32 +000035template <typename T> struct TestBaseSpecifiers { };
36template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
37
Andrew Trick220a9c82010-10-19 21:54:32 +000038//===----------------------------------------------------------------------===//
39#elif not defined(HEADER2)
40#define HEADER2
41//===----------------------------------------------------------------------===//
42// Dependent header for C++ chained PCH test
43
44// Overload function from primary
45void f(int);
46
47// Add function with different name
48void f2();
49
50// Reopen namespace
51namespace ns {
52 // Overload function from primary
53 void g(int);
54
55 // Add different name
56 void g2();
57}
58
59// Specialize template from primary
60template <>
61struct S<int> { typedef int I; };
62
63// Partially specialize
64template <typename T>
65struct S<T &> { typedef int J; };
66
67// Specialize previous partial specialization
68template <>
69struct S<int *> { typedef int K; };
70
71// Specialize the partial specialization from this file
72template <>
73struct S<int &> { typedef int L; };
74
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +000075template <typename T> struct TS2 { };
76
Anders Carlssonf25330b2011-03-09 05:09:32 +000077struct TestBaseSpecifiers3 { };
78struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
79
Anders Carlssonc8505782011-03-06 18:41:18 +000080struct A { };
81struct B : A { };
82
Andrew Trick220a9c82010-10-19 21:54:32 +000083//===----------------------------------------------------------------------===//
84#else
85//===----------------------------------------------------------------------===//
86
Sebastian Redl5967d622010-08-24 00:50:16 +000087void test() {
88 f();
89 f(1);
90 pf();
91 f2();
92
93 ns::g();
94 ns::g(1);
95 ns::pg();
96 ns::g2();
97
Sebastian Redl4153a062010-08-24 22:50:24 +000098 typedef S<double>::G T1;
99 typedef S<double *>::H T2;
100 typedef S<int>::I T3;
101 typedef S<double &>::J T4;
102 typedef S<int *>::K T5;
103 typedef S<int &>::L T6;
Argyrios Kyrtzidis9703b0d2010-10-20 00:11:15 +0000104
105 TS2int ts2;
Anders Carlssonc8505782011-03-06 18:41:18 +0000106
107 B b;
Sebastian Redl5967d622010-08-24 00:50:16 +0000108}
Andrew Trick220a9c82010-10-19 21:54:32 +0000109
110//===----------------------------------------------------------------------===//
111#endif