[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / chain-default-argument-instantiation.cpp
blob0accd544a3847af30c35b582d97dda4b6b450fb1
1 // Test default argument instantiation in chained PCH.
3 // Without PCH
4 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -include %s -include %s %s
6 // With PCH
7 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -chain-include %s -chain-include %s
9 // With modules
10 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fmodules %s -chain-include %s -chain-include %s
12 // expected-no-diagnostics
14 #ifndef HEADER1
15 #define HEADER1
16 //===----------------------------------------------------------------------===//
17 // Primary header.
19 namespace rdar23810407 {
20 template<typename T> int f(T t) {
21 extern T rdar23810407_variable;
22 return 0;
24 template<typename T> int g(int a = f([] {}));
27 //===----------------------------------------------------------------------===//
28 #elif not defined(HEADER2)
29 #define HEADER2
30 #if !defined(HEADER1)
31 #error Header inclusion order messed up
32 #endif
34 //===----------------------------------------------------------------------===//
35 // Dependent header.
37 inline void instantiate_once() {
38 rdar23810407::g<int>();
41 //===----------------------------------------------------------------------===//
42 #else
43 //===----------------------------------------------------------------------===//
45 void test() {
46 rdar23810407::g<int>();
49 //===----------------------------------------------------------------------===//
50 #endif