1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2 
3 template<typename T> void capture(const T&);
4 
5 class NonCopyable {
6   NonCopyable(const NonCopyable&); // expected-note 2 {{implicitly declared private here}}
7 };
8 
9 void capture_by_copy(NonCopyable nc, NonCopyable &ncr) {
10   // FIXME: error messages should talk about capture
11   (void)[nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
12              // expected-error{{lambda expressions are not supported yet}}
13   (void)[ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
14              // expected-error{{lambda expressions are not supported yet}}
15 }
16 
17 struct NonTrivial {
18   NonTrivial();
19   NonTrivial(const NonTrivial &);
20   ~NonTrivial();
21 };
22 
23 struct CopyCtorDefault {
24   CopyCtorDefault();
25   CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial());
26 
27   void foo() const;
28 };
29 
30 void capture_with_default_args(CopyCtorDefault cct) {
31   (void)[=] () -> void { cct.foo(); }; // expected-error{{lambda expressions are not supported yet}}
32 }
33 
34 struct ExpectedArrayLayout {
35   CopyCtorDefault array[3];
36 };
37 
38 void capture_array() {
39   CopyCtorDefault array[3];
40   auto x = [=]() -> void { // expected-error{{lambda expressions are not supported yet}}
41     capture(array[0]);
42   };
43   static_assert(sizeof(x) == sizeof(ExpectedArrayLayout), "layout mismatch");
44 }
45 
46 // Check for the expected non-static data members.
47 
48 struct ExpectedLayout {
49   char a;
50   short b;
51 };
52 
53 void test_layout(char a, short b) {
54   auto x = [=] () -> void { // expected-error{{lambda expressions are not supported yet}}
55     capture(a);
56     capture(b);
57   };
58   static_assert(sizeof(x) == sizeof(ExpectedLayout), "Layout mismatch!");
59 }
60