Shih-wei Liao | f8fd82b | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | typedef int INT; |
| 3 | |
| 4 | class Foo { |
| 5 | Foo(); |
| 6 | (Foo)(float) { } |
| 7 | explicit Foo(int); // expected-note {{previous declaration is here}} |
| 8 | Foo(const Foo&); |
| 9 | |
| 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 | |
| 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 | }; |
| 20 | |
| 21 | Foo::Foo(const Foo&) { } |
| 22 | |
| 23 | typedef struct { |
| 24 | int version; |
| 25 | } Anon; |
| 26 | extern const Anon anon; |
| 27 | extern "C" const Anon anon2; |
| 28 | |
| 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; |
| 39 | |
| 40 | struct Length { |
| 41 | Length l() const { return *this; } |
| 42 | }; |
| 43 | |
| 44 | // <rdar://problem/6815988> |
| 45 | struct mmst_reg{ |
| 46 | char mmst_reg[10]; |
| 47 | }; |
| 48 | |
| 49 | // PR3948 |
| 50 | namespace PR3948 { |
| 51 | // PR3948 |
| 52 | class a { |
| 53 | public: |
| 54 | int b(int a()); |
| 55 | }; |
| 56 | int x(); |
| 57 | void y() { |
| 58 | a z; z.b(x); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | namespace A { |
| 63 | struct S { |
| 64 | S(); |
| 65 | S(int); |
| 66 | void f1(); |
| 67 | void f2(); |
| 68 | operator int (); |
| 69 | ~S(); |
| 70 | }; |
| 71 | } |
| 72 | |
| 73 | A::S::S() {} |
| 74 | |
| 75 | void A::S::f1() {} |
| 76 | |
| 77 | struct S {}; |
| 78 | |
| 79 | A::S::S(int) {} |
| 80 | |
| 81 | void A::S::f2() {} |
| 82 | |
| 83 | A::S::operator int() { return 1; } |
| 84 | |
| 85 | A::S::~S() {} |
| 86 | |