Alexis Hunt | 61bc173 | 2011-05-01 07:04:31 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s |
| 2 | |
| 3 | struct foo { |
| 4 | int i; |
| 5 | foo(); |
| 6 | foo(int); |
| 7 | foo(int, int); |
| 8 | foo(bool); |
| 9 | foo(char); |
Alexis Hunt | 9d47faf | 2011-05-03 23:05:34 +0000 | [diff] [blame^] | 10 | foo(const float*); |
| 11 | foo(const float&); |
| 12 | foo(void*); |
Alexis Hunt | 61bc173 | 2011-05-01 07:04:31 +0000 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | // Good |
| 16 | foo::foo (int i) : i(i) { |
| 17 | } |
| 18 | // Good |
| 19 | foo::foo () : foo(-1) { |
| 20 | } |
| 21 | // Good |
| 22 | foo::foo (int, int) : foo() { |
| 23 | } |
| 24 | |
| 25 | foo::foo (bool) : foo(true) { // expected-error{{delegates to itself}} |
| 26 | } |
| 27 | |
| 28 | // Good |
Alexis Hunt | 9d47faf | 2011-05-03 23:05:34 +0000 | [diff] [blame^] | 29 | foo::foo (const float* f) : foo(*f) { |
Alexis Hunt | 61bc173 | 2011-05-01 07:04:31 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | // FIXME: This should error |
Alexis Hunt | 9d47faf | 2011-05-03 23:05:34 +0000 | [diff] [blame^] | 33 | foo::foo (const float &f) : foo(&f) { |
Alexis Hunt | 61bc173 | 2011-05-01 07:04:31 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | foo::foo (char) : i(3), foo(3) { // expected-error{{must appear alone}} |
| 37 | } |
Alexis Hunt | 9d47faf | 2011-05-03 23:05:34 +0000 | [diff] [blame^] | 38 | |
| 39 | // This should not cause an infinite loop |
| 40 | foo::foo (void*) : foo(4.0f) { |
| 41 | } |
| 42 | |
| 43 | struct deleted_dtor { |
| 44 | ~deleted_dtor() = delete; // expected-note{{function has been explicitly marked deleted here}} |
| 45 | deleted_dtor(); |
| 46 | deleted_dtor(int) : deleted_dtor() // expected-error{{attempt to use a deleted function}} |
| 47 | {} |
| 48 | }; |