Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify |
| 2 | |
Douglas Gregor | 199cec7 | 2012-02-09 02:45:47 +0000 | [diff] [blame^] | 3 | template<typename T> void capture(const T&); |
| 4 | |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 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 |
Douglas Gregor | 8c50e7c | 2012-02-09 00:47:04 +0000 | [diff] [blame] | 11 | (void)[nc] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \ |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 12 | // expected-error{{lambda expressions are not supported yet}} |
Douglas Gregor | 8c50e7c | 2012-02-09 00:47:04 +0000 | [diff] [blame] | 13 | (void)[ncr] { }; // expected-error{{field of type 'NonCopyable' has private copy constructor}} \ |
Douglas Gregor | e31e606 | 2012-02-07 10:09:13 +0000 | [diff] [blame] | 14 | // expected-error{{lambda expressions are not supported yet}} |
| 15 | } |
| 16 | |
Douglas Gregor | 8c50e7c | 2012-02-09 00:47:04 +0000 | [diff] [blame] | 17 | struct NonTrivial { |
| 18 | NonTrivial(); |
| 19 | NonTrivial(const NonTrivial &); |
| 20 | ~NonTrivial(); |
| 21 | }; |
| 22 | |
| 23 | struct CopyCtorDefault { |
Douglas Gregor | 199cec7 | 2012-02-09 02:45:47 +0000 | [diff] [blame^] | 24 | CopyCtorDefault(); |
Douglas Gregor | 8c50e7c | 2012-02-09 00:47:04 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | 199cec7 | 2012-02-09 02:45:47 +0000 | [diff] [blame^] | 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 | } |
Douglas Gregor | 3d23f788 | 2012-02-09 02:12:34 +0000 | [diff] [blame] | 45 | |
| 46 | // Check for the expected non-static data members. |
| 47 | |
| 48 | struct ExpectedLayout { |
| 49 | char a; |
| 50 | short b; |
| 51 | }; |
| 52 | |
Douglas Gregor | 3d23f788 | 2012-02-09 02:12:34 +0000 | [diff] [blame] | 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 | } |