Richard Smith | b8abff6 | 2012-11-28 03:45:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Fariborz Jahanian | 52ab92b | 2009-08-06 17:22:51 +0000 | [diff] [blame] | 2 | |
Douglas Gregor | 90f9382 | 2009-12-22 22:17:25 +0000 | [diff] [blame] | 3 | struct S { |
| 4 | S (S); // expected-error {{copy constructor must pass its first argument by reference}} |
Fariborz Jahanian | 52ab92b | 2009-08-06 17:22:51 +0000 | [diff] [blame] | 5 | }; |
| 6 | |
| 7 | S f(); |
| 8 | |
| 9 | void g() { |
Douglas Gregor | 90f9382 | 2009-12-22 22:17:25 +0000 | [diff] [blame] | 10 | S a( f() ); |
Fariborz Jahanian | 52ab92b | 2009-08-06 17:22:51 +0000 | [diff] [blame] | 11 | } |
Douglas Gregor | fd47648 | 2009-11-13 23:59:09 +0000 | [diff] [blame] | 12 | |
Richard Smith | b8abff6 | 2012-11-28 03:45:24 +0000 | [diff] [blame] | 13 | class foo { |
| 14 | foo(foo&, int); // expected-note {{previous}} |
| 15 | foo(int); // expected-note {{previous}} |
| 16 | foo(const foo&); // expected-note {{previous}} |
| 17 | }; |
| 18 | |
| 19 | foo::foo(foo&, int = 0) { } // expected-error {{makes this constructor a copy constructor}} |
| 20 | foo::foo(int = 0) { } // expected-error {{makes this constructor a default constructor}} |
| 21 | foo::foo(const foo& = 0) { } //expected-error {{makes this constructor a default constructor}} |
| 22 | |
Douglas Gregor | 2366cd5 | 2010-03-02 18:48:07 +0000 | [diff] [blame] | 23 | namespace PR6064 { |
| 24 | struct A { |
| 25 | A() { } |
Richard Smith | b8abff6 | 2012-11-28 03:45:24 +0000 | [diff] [blame] | 26 | inline A(A&, int); // expected-note {{previous}} |
Douglas Gregor | 2366cd5 | 2010-03-02 18:48:07 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
Richard Smith | b8abff6 | 2012-11-28 03:45:24 +0000 | [diff] [blame] | 29 | A::A(A&, int = 0) { } // expected-error {{makes this constructor a copy constructor}} |
Douglas Gregor | 2366cd5 | 2010-03-02 18:48:07 +0000 | [diff] [blame] | 30 | |
| 31 | void f() { |
| 32 | A const a; |
| 33 | A b(a); |
| 34 | } |
| 35 | } |
Richard Smith | b8abff6 | 2012-11-28 03:45:24 +0000 | [diff] [blame] | 36 | |
| 37 | namespace PR10618 { |
| 38 | struct A { |
| 39 | A(int, int, int); // expected-note {{previous}} |
| 40 | }; |
| 41 | A::A(int a = 0, // expected-error {{makes this constructor a default constructor}} |
| 42 | int b = 0, |
| 43 | int c = 0) {} |
| 44 | |
| 45 | struct B { |
| 46 | B(int); |
| 47 | B(const B&, int); // expected-note {{previous}} |
| 48 | }; |
| 49 | B::B(const B& = B(0), // expected-error {{makes this constructor a default constructor}} |
| 50 | int = 0) { |
| 51 | } |
| 52 | |
| 53 | struct C { |
| 54 | C(const C&, int); // expected-note {{previous}} |
| 55 | }; |
| 56 | C::C(const C&, |
| 57 | int = 0) { // expected-error {{makes this constructor a copy constructor}} |
| 58 | } |
| 59 | } |