xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/captured-stmt.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c++-header -emit-pch %s -o %t
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // expected-no-diagnostics
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc #ifndef HEADER_INCLUDED
7*f4a2713aSLionel Sambuc #define HEADER_INCLUDED
8*f4a2713aSLionel Sambuc 
foo(int & x,int y)9*f4a2713aSLionel Sambuc static inline void foo(int &x, int y) {
10*f4a2713aSLionel Sambuc   // Capturing x and y
11*f4a2713aSLionel Sambuc   #pragma clang __debug captured
12*f4a2713aSLionel Sambuc   {
13*f4a2713aSLionel Sambuc     x += y;
14*f4a2713aSLionel Sambuc   }
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc struct C {
18*f4a2713aSLionel Sambuc   int val;
19*f4a2713aSLionel Sambuc 
CC20*f4a2713aSLionel Sambuc   explicit C(int v) : val(v) { }
21*f4a2713aSLionel Sambuc 
barC22*f4a2713aSLionel Sambuc   void bar(int &x) {
23*f4a2713aSLionel Sambuc     // Capturing x and this
24*f4a2713aSLionel Sambuc     #pragma clang __debug captured
25*f4a2713aSLionel Sambuc     {
26*f4a2713aSLionel Sambuc       x += val;
27*f4a2713aSLionel Sambuc     }
28*f4a2713aSLionel Sambuc   }
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc #else
32*f4a2713aSLionel Sambuc 
test_foo(int & x)33*f4a2713aSLionel Sambuc void test_foo(int &x) {
34*f4a2713aSLionel Sambuc   foo(x, 10);
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc 
test_bar(int & x)37*f4a2713aSLionel Sambuc void test_bar(int &x) {
38*f4a2713aSLionel Sambuc   C Obj(10);
39*f4a2713aSLionel Sambuc   Obj.bar(x);
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc #endif
43