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