Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 2 | typedef int INT; |
| 3 | |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 4 | class Foo { |
| 5 | Foo(); |
| 6 | (Foo)(float) { } |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 7 | explicit Foo(int); // expected-note {{previous declaration is here}} |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 8 | Foo(const Foo&); |
| 9 | |
Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 10 | ((Foo))(INT); // expected-error{{cannot be redeclared}} |
| 11 | |
| 12 | Foo(Foo foo, int i = 17, int j = 42); // expected-error {{copy constructor must pass its first argument by reference}} |
| 13 | |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 14 | static Foo(short, short); // expected-error{{constructor cannot be declared 'static'}} |
| 15 | virtual Foo(double); // expected-error{{constructor cannot be declared 'virtual'}} |
| 16 | Foo(long) const; // expected-error{{'const' qualifier is not allowed on a constructor}} |
| 17 | |
| 18 | int Foo(int, int); // expected-error{{constructor cannot have a return type}} |
| 19 | }; |
Douglas Gregor | 9d35097 | 2008-12-12 08:25:50 +0000 | [diff] [blame] | 20 | |
| 21 | Foo::Foo(const Foo&) { } |
| 22 | |
Douglas Gregor | 9e7d9de | 2008-12-15 21:24:18 +0000 | [diff] [blame] | 23 | typedef struct { |
| 24 | int version; |
| 25 | } Anon; |
| 26 | extern const Anon anon; |
| 27 | extern "C" const Anon anon2; |
| 28 | |
Sebastian Redl | 1f5432c | 2008-12-23 16:41:32 +0000 | [diff] [blame] | 29 | // PR3188: The extern declaration complained about not having an appropriate |
| 30 | // constructor. |
| 31 | struct x; |
| 32 | extern x a; |
| 33 | |
| 34 | // A similar case. |
| 35 | struct y { |
| 36 | y(int); |
| 37 | }; |
| 38 | extern y b; |
Douglas Gregor | 61366e9 | 2008-12-24 00:01:03 +0000 | [diff] [blame^] | 39 | |
| 40 | struct Length { |
| 41 | Length l() const { return *this; } |
| 42 | }; |