1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -fblocks
2 
3 void test_nest_lambda() {
4   int x;
5   int y;
6   [&,y]() {
7     int z;
8     #pragma clang __debug captured
9     {
10       x = y; // OK
11       y = z; // expected-error{{cannot assign to a variable captured by copy in a non-mutable lambda}}
12       z = y; // OK
13     }
14   }();
15 
16   int a;
17   #pragma clang __debug captured
18   {
19     int b;
20     int c;
21     [&,c]() {
22       a = b; // OK
23       b = c; // OK
24       c = a; // expected-error{{cannot assign to a variable captured by copy in a non-mutable lambda}}
25     }();
26   }
27 }
28 
29 class test_obj_capture {
30   int a;
31   void b();
32   static void test() {
33     test_obj_capture c;
34     #pragma clang __debug captured
35     { (void)c.a; }  // OK
36     #pragma clang __debug captured
37     { c.b(); }      // OK
38   }
39 };
40 
41 class test_this_capture {
42   int a;
43   void b();
44   void test() {
45     #pragma clang __debug captured
46     { (void)this; } // OK
47     #pragma clang __debug captured
48     { (void)a; }    // OK
49     #pragma clang __debug captured
50     { b(); }        // OK
51   }
52 };
53