From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/PCH/chain-cxx.cpp | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 clang/test/PCH/chain-cxx.cpp (limited to 'clang/test/PCH/chain-cxx.cpp') diff --git a/clang/test/PCH/chain-cxx.cpp b/clang/test/PCH/chain-cxx.cpp new file mode 100644 index 0000000..0d50e61 --- /dev/null +++ b/clang/test/PCH/chain-cxx.cpp @@ -0,0 +1,142 @@ +// Test C++ chained PCH functionality + +// Without PCH +// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s + +// With PCH +// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s + +#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 +struct S { typedef int G; }; + +// Partially specialize +template +struct S { typedef int H; }; + +template struct TS2; +typedef TS2 TS2int; + +template struct TestBaseSpecifiers { }; +template struct TestBaseSpecifiers2 : TestBaseSpecifiers { }; + +template +struct TS3 { + static const int value = 0; + static const int value2; +}; +template +const int TS3::value; +template +const int TS3::value2 = 1; +// Instantiate struct, but not value. +struct instantiate : TS3 {}; + +// Typedef +typedef int Integer; + +//===----------------------------------------------------------------------===// +#elif not defined(HEADER2) +#define HEADER2 +#if !defined(HEADER1) +#error Header inclusion order messed up +#endif + +//===----------------------------------------------------------------------===// +// 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 { typedef int I; }; + +// Partially specialize +template +struct S { typedef int J; }; + +// Specialize previous partial specialization +template <> +struct S { typedef int K; }; + +// Specialize the partial specialization from this file +template <> +struct S { typedef int L; }; + +template struct TS2 { }; + +struct TestBaseSpecifiers3 { }; +struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { }; + +struct A { }; +struct B : A { }; + +// Instantiate TS3's members. +static const int ts3m1 = TS3::value; +extern int arr[TS3::value2]; + +// Redefinition of typedef +typedef int Integer; + +//===----------------------------------------------------------------------===// +#else +//===----------------------------------------------------------------------===// + +void test() { + f(); + f(1); + pf(); + f2(); + + ns::g(); + ns::g(1); + ns::pg(); + ns::g2(); + + typedef S::G T1; + typedef S::H T2; + typedef S::I T3; + typedef S::J T4; + typedef S::K T5; + typedef S::L T6; + + TS2int ts2; + + B b; + Integer i = 17; +} + +// Should have remembered that there is a definition. +static const int ts3m2 = TS3::value; +int arr[TS3::value2]; + +//===----------------------------------------------------------------------===// +#endif -- cgit v1.2.3