blob: f3b910d2f5a3bf06b946b8e14a3c47d96da6371f [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor030ff0c2008-10-31 20:25:05 +00002typedef int INT;
3
Douglas Gregorb48fe382008-10-31 09:07:45 +00004class Foo {
5 Foo();
6 (Foo)(float) { }
Chris Lattner5f4a6822008-11-23 23:12:31 +00007 explicit Foo(int); // expected-note {{previous declaration is here}}
Douglas Gregorb48fe382008-10-31 09:07:45 +00008 Foo(const Foo&);
9
Douglas Gregor030ff0c2008-10-31 20:25:05 +000010 ((Foo))(INT); // expected-error{{cannot be redeclared}}
11
Douglas Gregor33297562009-03-27 04:38:56 +000012 Foo(Foo foo, int i = 17, int j = 42); // expected-error{{copy constructor must pass its first argument by reference}}
Douglas Gregor030ff0c2008-10-31 20:25:05 +000013
Douglas Gregorb48fe382008-10-31 09:07:45 +000014 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 Gregor3f9a0562009-11-03 01:35:08 +000017
Douglas Gregora6e937c2010-10-15 13:21:21 +000018 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 Gregorb48fe382008-10-31 09:07:45 +000020};
Douglas Gregor9d350972008-12-12 08:25:50 +000021
22Foo::Foo(const Foo&) { }
23
Douglas Gregor9e7d9de2008-12-15 21:24:18 +000024typedef struct {
25 int version;
26} Anon;
27extern const Anon anon;
28extern "C" const Anon anon2;
29
Sebastian Redl1f5432c2008-12-23 16:41:32 +000030// PR3188: The extern declaration complained about not having an appropriate
31// constructor.
32struct x;
33extern x a;
34
35// A similar case.
36struct y {
37 y(int);
38};
39extern y b;
Douglas Gregor61366e92008-12-24 00:01:03 +000040
41struct Length {
42 Length l() const { return *this; }
43};
Anders Carlsson5a8cb0b2009-04-29 23:19:39 +000044
45// <rdar://problem/6815988>
46struct mmst_reg{
47 char mmst_reg[10];
48};
Anders Carlsson4649cac2009-04-30 22:41:11 +000049
50// PR3948
51namespace PR3948 {
52// PR3948
53class a {
54 public:
55 int b(int a());
56};
57int x();
58void y() {
59 a z; z.b(x);
60}
61}
Douglas Gregor675431d2009-07-06 16:40:48 +000062
63namespace A {
64 struct S {
65 S();
66 S(int);
67 void f1();
68 void f2();
69 operator int ();
70 ~S();
71 };
72}
73
74A::S::S() {}
75
76void A::S::f1() {}
77
78struct S {};
79
80A::S::S(int) {}
81
82void A::S::f2() {}
83
84A::S::operator int() { return 1; }
85
86A::S::~S() {}
Douglas Gregora1d71ae2009-08-24 12:17:54 +000087