xref: /aosp_15_r20/external/clang/test/PCH/cxx1y-init-captures.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1 // No PCH:
2 // RUN: %clang_cc1 -pedantic -std=c++1y -include %s -verify %s
3 //
4 // With PCH:
5 // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
6 // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
7 
8 #ifndef HEADER
9 #define HEADER
10 
__anon3fa3d6570102() 11 auto counter = [a(0)] () mutable { return a++; };
12 int x = counter();
13 
f(T t)14 template<typename T> void f(T t) {
15   [t(t)] { int n = t; } ();
16 }
17 
18 #else
19 
20 int y = counter();
21 
g()22 void g() {
23   f(0); // ok
24   // expected-error@15 {{lvalue of type 'const char *const'}}
25   f("foo"); // expected-note {{here}}
26 }
27 
28 #endif
29