2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2008-11-01 04:25:05 +08:00
|
|
|
typedef int INT;
|
|
|
|
|
2008-10-31 17:07:45 +08:00
|
|
|
class Foo {
|
|
|
|
Foo();
|
|
|
|
(Foo)(float) { }
|
2008-11-24 07:12:31 +08:00
|
|
|
explicit Foo(int); // expected-note {{previous declaration is here}}
|
2008-10-31 17:07:45 +08:00
|
|
|
Foo(const Foo&);
|
|
|
|
|
2008-11-01 04:25:05 +08:00
|
|
|
((Foo))(INT); // expected-error{{cannot be redeclared}}
|
|
|
|
|
2009-03-27 12:38:56 +08:00
|
|
|
Foo(Foo foo, int i = 17, int j = 42); // expected-error{{copy constructor must pass its first argument by reference}}
|
2008-11-01 04:25:05 +08:00
|
|
|
|
2008-10-31 17:07:45 +08:00
|
|
|
static Foo(short, short); // expected-error{{constructor cannot be declared 'static'}}
|
|
|
|
virtual Foo(double); // expected-error{{constructor cannot be declared 'virtual'}}
|
|
|
|
Foo(long) const; // expected-error{{'const' qualifier is not allowed on a constructor}}
|
2009-11-03 09:35:08 +08:00
|
|
|
|
2010-10-15 21:21:21 +08:00
|
|
|
int Foo(int, int); // expected-error{{constructor cannot have a return type}} \
|
|
|
|
// expected-error{{member 'Foo' has the same name as its class}}
|
2014-07-09 02:18:04 +08:00
|
|
|
|
|
|
|
volatile Foo(float); // expected-error{{constructor cannot have a return type}}
|
2008-10-31 17:07:45 +08:00
|
|
|
};
|
2008-12-12 16:25:50 +08:00
|
|
|
|
|
|
|
Foo::Foo(const Foo&) { }
|
|
|
|
|
2008-12-16 05:24:18 +08:00
|
|
|
typedef struct {
|
|
|
|
int version;
|
|
|
|
} Anon;
|
|
|
|
extern const Anon anon;
|
|
|
|
extern "C" const Anon anon2;
|
|
|
|
|
2008-12-24 00:41:32 +08:00
|
|
|
// PR3188: The extern declaration complained about not having an appropriate
|
|
|
|
// constructor.
|
|
|
|
struct x;
|
|
|
|
extern x a;
|
|
|
|
|
|
|
|
// A similar case.
|
|
|
|
struct y {
|
|
|
|
y(int);
|
|
|
|
};
|
|
|
|
extern y b;
|
2008-12-24 08:01:03 +08:00
|
|
|
|
|
|
|
struct Length {
|
|
|
|
Length l() const { return *this; }
|
|
|
|
};
|
2009-04-30 07:19:39 +08:00
|
|
|
|
|
|
|
// <rdar://problem/6815988>
|
|
|
|
struct mmst_reg{
|
|
|
|
char mmst_reg[10];
|
|
|
|
};
|
2009-05-01 06:41:11 +08:00
|
|
|
|
|
|
|
// PR3948
|
|
|
|
namespace PR3948 {
|
|
|
|
// PR3948
|
|
|
|
class a {
|
|
|
|
public:
|
|
|
|
int b(int a());
|
|
|
|
};
|
|
|
|
int x();
|
|
|
|
void y() {
|
|
|
|
a z; z.b(x);
|
|
|
|
}
|
|
|
|
}
|
2009-07-07 00:40:48 +08:00
|
|
|
|
|
|
|
namespace A {
|
|
|
|
struct S {
|
|
|
|
S();
|
|
|
|
S(int);
|
|
|
|
void f1();
|
|
|
|
void f2();
|
|
|
|
operator int ();
|
|
|
|
~S();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
A::S::S() {}
|
|
|
|
|
|
|
|
void A::S::f1() {}
|
|
|
|
|
|
|
|
struct S {};
|
|
|
|
|
|
|
|
A::S::S(int) {}
|
|
|
|
|
|
|
|
void A::S::f2() {}
|
|
|
|
|
|
|
|
A::S::operator int() { return 1; }
|
|
|
|
|
|
|
|
A::S::~S() {}
|
2009-08-24 20:17:54 +08:00
|
|
|
|