[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / chain-cxx.cpp
blob6e9c1743fbd7e3a59b89d4a5098e791f4e8a42db
1 // Test C++ chained PCH functionality
3 // Without PCH
4 // RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
6 // With PCH
7 // RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
9 // With modules
10 // RUN: %clang_cc1 -fsyntax-only -verify -fmodules %s -chain-include %s -chain-include %s
12 // expected-no-diagnostics
14 #ifndef HEADER1
15 #define HEADER1
16 //===----------------------------------------------------------------------===//
17 // Primary header for C++ chained PCH test
19 void f();
21 // Name not appearing in dependent
22 void pf();
24 namespace ns {
25 void g();
27 void pg();
30 template <typename T>
31 struct S { typedef int G; };
33 // Partially specialize
34 template <typename T>
35 struct S<T *> { typedef int H; };
37 template <typename T> struct TS2;
38 typedef TS2<int> TS2int;
40 template <typename T> struct TestBaseSpecifiers { };
41 template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
43 template <typename T>
44 struct TS3 {
45 static const int value = 0;
46 static const int value2;
48 template <typename T>
49 const int TS3<T>::value;
50 template <typename T>
51 const int TS3<T>::value2 = 1;
52 // Instantiate struct, but not value.
53 struct instantiate : TS3<int> {};
55 // Typedef
56 typedef int Integer;
58 //===----------------------------------------------------------------------===//
59 #elif not defined(HEADER2)
60 #define HEADER2
61 #if !defined(HEADER1)
62 #error Header inclusion order messed up
63 #endif
65 //===----------------------------------------------------------------------===//
66 // Dependent header for C++ chained PCH test
68 // Overload function from primary
69 void f(int);
71 // Add function with different name
72 void f2();
74 // Reopen namespace
75 namespace ns {
76 // Overload function from primary
77 void g(int);
79 // Add different name
80 void g2();
83 // Specialize template from primary
84 template <>
85 struct S<int> { typedef int I; };
87 // Partially specialize
88 template <typename T>
89 struct S<T &> { typedef int J; };
91 // Specialize previous partial specialization
92 template <>
93 struct S<int *> { typedef int K; };
95 // Specialize the partial specialization from this file
96 template <>
97 struct S<int &> { typedef int L; };
99 template <typename T> struct TS2 { };
101 struct TestBaseSpecifiers3 { };
102 struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
104 struct A { };
105 struct B : A { };
107 // Instantiate TS3's members.
108 static const int ts3m1 = TS3<int>::value;
109 extern int arr[TS3<int>::value2];
111 // Redefinition of typedef
112 typedef int Integer;
114 //===----------------------------------------------------------------------===//
115 #else
116 //===----------------------------------------------------------------------===//
118 void test() {
119 f();
120 f(1);
121 pf();
122 f2();
124 ns::g();
125 ns::g(1);
126 ns::pg();
127 ns::g2();
129 typedef S<double>::G T1;
130 typedef S<double *>::H T2;
131 typedef S<int>::I T3;
132 typedef S<double &>::J T4;
133 typedef S<int *>::K T5;
134 typedef S<int &>::L T6;
136 TS2int ts2;
138 B b;
139 Integer i = 17;
142 // Should have remembered that there is a definition.
143 static const int ts3m2 = TS3<int>::value;
144 int arr[TS3<int>::value2];
146 //===----------------------------------------------------------------------===//
147 #endif