[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / chain-staticvar-instantiation.cpp
blob850b8d185e3cc539bb5a66cfcb32cc0dfea71f56
1 // Without PCH
2 // RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
4 // With PCH
5 // RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
7 #ifndef HEADER1
8 #define HEADER1
9 //===----------------------------------------------------------------------===//
11 namespace NS {
13 template <class _Tp, _Tp __v>
14 struct TS
16 static const _Tp value = __v;
19 template <class _Tp, _Tp __v>
20 const _Tp TS<_Tp, __v>::value;
22 TS<int, 2> g1;
26 //===----------------------------------------------------------------------===//
27 #elif not defined(HEADER2)
28 #define HEADER2
29 #if !defined(HEADER1)
30 #error Header inclusion order messed up
31 #endif
33 int g2 = NS::TS<int, 2>::value;
35 //===----------------------------------------------------------------------===//
36 #else
37 //===----------------------------------------------------------------------===//
39 // expected-warning@+1 {{reached main file}}
40 #warning reached main file
42 int g3 = NS::TS<int, 2>::value;
44 //===----------------------------------------------------------------------===//
45 #endif