blob: 2dcaa5ddf634689c1a5176dbc72b24611da60bb2 [file] [log] [blame]
Douglas Gregore31e6062012-02-07 10:09:13 +00001// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2
Douglas Gregor199cec72012-02-09 02:45:47 +00003template<typename T> void capture(const T&);
4
Douglas Gregore31e6062012-02-07 10:09:13 +00005class NonCopyable {
6 NonCopyable(const NonCopyable&); // expected-note 2 {{implicitly declared private here}}
7};
8
9void capture_by_copy(NonCopyable nc, NonCopyable &ncr) {
10 // FIXME: error messages should talk about capture
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000011 (void)[nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
Douglas Gregore31e6062012-02-07 10:09:13 +000012 // expected-error{{lambda expressions are not supported yet}}
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000013 (void)[ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \
Douglas Gregore31e6062012-02-07 10:09:13 +000014 // expected-error{{lambda expressions are not supported yet}}
15}
16
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000017struct NonTrivial {
18 NonTrivial();
19 NonTrivial(const NonTrivial &);
20 ~NonTrivial();
21};
22
23struct CopyCtorDefault {
Douglas Gregor199cec72012-02-09 02:45:47 +000024 CopyCtorDefault();
Douglas Gregor8c50e7c2012-02-09 00:47:04 +000025 CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial());
26
27 void foo() const;
28};
29
30void capture_with_default_args(CopyCtorDefault cct) {
31 (void)[=] () -> void { cct.foo(); }; // expected-error{{lambda expressions are not supported yet}}
32}
33
Douglas Gregor199cec72012-02-09 02:45:47 +000034struct ExpectedArrayLayout {
35 CopyCtorDefault array[3];
36};
37
38void 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}
Douglas Gregor3d23f7882012-02-09 02:12:34 +000045
46// Check for the expected non-static data members.
47
48struct ExpectedLayout {
49 char a;
50 short b;
51};
52
Douglas Gregor3d23f7882012-02-09 02:12:34 +000053void 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}