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