| Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -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 |  | 
| Douglas Gregor | 3329756 | 2009-03-27 04:38:56 +0000 | [diff] [blame] | 12 |   Foo(Foo foo, int i = 17, int j = 42); // expected-error{{copy constructor must pass its first argument by reference}} | 
| Douglas Gregor | 030ff0c | 2008-10-31 20:25:05 +0000 | [diff] [blame] | 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}} | 
| Douglas Gregor | 3f9a056 | 2009-11-03 01:35:08 +0000 | [diff] [blame] | 17 |    | 
| Douglas Gregor | a6e937c | 2010-10-15 13:21:21 +0000 | [diff] [blame] | 18 |   int Foo(int, int); // expected-error{{constructor cannot have a return type}} \ | 
 | 19 |   // expected-error{{member 'Foo' has the same name as its class}} | 
| Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 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; | 
| Douglas Gregor | 61366e9 | 2008-12-24 00:01:03 +0000 | [diff] [blame] | 40 |  | 
 | 41 | struct Length { | 
 | 42 |   Length l() const { return *this; } | 
 | 43 | }; | 
| Anders Carlsson | 5a8cb0b | 2009-04-29 23:19:39 +0000 | [diff] [blame] | 44 |  | 
 | 45 | // <rdar://problem/6815988> | 
 | 46 | struct mmst_reg{ | 
 | 47 |  char mmst_reg[10]; | 
 | 48 | }; | 
| Anders Carlsson | 4649cac | 2009-04-30 22:41:11 +0000 | [diff] [blame] | 49 |  | 
 | 50 | // PR3948 | 
 | 51 | namespace PR3948 { | 
 | 52 | // PR3948 | 
 | 53 | class a { | 
 | 54 |   public: | 
 | 55 |   int b(int a()); | 
 | 56 | }; | 
 | 57 | int x(); | 
 | 58 | void y() { | 
 | 59 |   a z; z.b(x); | 
 | 60 | } | 
 | 61 | } | 
| Douglas Gregor | 675431d | 2009-07-06 16:40:48 +0000 | [diff] [blame] | 62 |  | 
 | 63 | namespace A { | 
 | 64 |   struct S { | 
 | 65 |     S(); | 
 | 66 |     S(int); | 
 | 67 |     void f1(); | 
 | 68 |     void f2(); | 
 | 69 |     operator int (); | 
 | 70 |     ~S(); | 
 | 71 |   }; | 
 | 72 | } | 
 | 73 |  | 
 | 74 | A::S::S() {} | 
 | 75 |  | 
 | 76 | void A::S::f1() {} | 
 | 77 |  | 
 | 78 | struct S {}; | 
 | 79 |  | 
 | 80 | A::S::S(int) {} | 
 | 81 |  | 
 | 82 | void A::S::f2() {} | 
 | 83 |  | 
 | 84 | A::S::operator int() { return 1; } | 
 | 85 |  | 
 | 86 | A::S::~S() {} | 
| Douglas Gregor | a1d71ae | 2009-08-24 12:17:54 +0000 | [diff] [blame] | 87 |  |