2010-08-24 08:50:16 +08:00
|
|
|
// Test C++ chained PCH functionality
|
|
|
|
|
|
|
|
// Without PCH
|
2010-10-20 05:54:32 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
|
2010-08-24 08:50:16 +08:00
|
|
|
|
|
|
|
// With PCH
|
2010-10-20 05:54:32 +08:00
|
|
|
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t1 %s
|
|
|
|
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t2 %s -include-pch %t1 -chained-pch
|
2010-08-24 08:50:16 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
|
|
|
|
|
2010-10-20 05:54:32 +08:00
|
|
|
#ifndef HEADER1
|
|
|
|
#define HEADER1
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Primary header for C++ chained PCH test
|
|
|
|
|
|
|
|
void f();
|
|
|
|
|
|
|
|
// Name not appearing in dependent
|
|
|
|
void pf();
|
|
|
|
|
|
|
|
namespace ns {
|
|
|
|
void g();
|
|
|
|
|
|
|
|
void pg();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct S { typedef int G; };
|
|
|
|
|
|
|
|
// Partially specialize
|
|
|
|
template <typename T>
|
|
|
|
struct S<T *> { typedef int H; };
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#elif not defined(HEADER2)
|
|
|
|
#define HEADER2
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Dependent header for C++ chained PCH test
|
|
|
|
|
|
|
|
// Overload function from primary
|
|
|
|
void f(int);
|
|
|
|
|
|
|
|
// Add function with different name
|
|
|
|
void f2();
|
|
|
|
|
|
|
|
// Reopen namespace
|
|
|
|
namespace ns {
|
|
|
|
// Overload function from primary
|
|
|
|
void g(int);
|
|
|
|
|
|
|
|
// Add different name
|
|
|
|
void g2();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Specialize template from primary
|
|
|
|
template <>
|
|
|
|
struct S<int> { typedef int I; };
|
|
|
|
|
|
|
|
// Partially specialize
|
|
|
|
template <typename T>
|
|
|
|
struct S<T &> { typedef int J; };
|
|
|
|
|
|
|
|
// Specialize previous partial specialization
|
|
|
|
template <>
|
|
|
|
struct S<int *> { typedef int K; };
|
|
|
|
|
|
|
|
// Specialize the partial specialization from this file
|
|
|
|
template <>
|
|
|
|
struct S<int &> { typedef int L; };
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#else
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-24 08:50:16 +08:00
|
|
|
void test() {
|
|
|
|
f();
|
|
|
|
f(1);
|
|
|
|
pf();
|
|
|
|
f2();
|
|
|
|
|
|
|
|
ns::g();
|
|
|
|
ns::g(1);
|
|
|
|
ns::pg();
|
|
|
|
ns::g2();
|
|
|
|
|
2010-08-25 06:50:24 +08:00
|
|
|
typedef S<double>::G T1;
|
|
|
|
typedef S<double *>::H T2;
|
|
|
|
typedef S<int>::I T3;
|
|
|
|
typedef S<double &>::J T4;
|
|
|
|
typedef S<int *>::K T5;
|
|
|
|
typedef S<int &>::L T6;
|
2010-08-24 08:50:16 +08:00
|
|
|
}
|
2010-10-20 05:54:32 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#endif
|