2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2008-10-07 01:10:33 +08:00
|
|
|
|
|
|
|
int x(1);
|
2008-10-07 18:21:57 +08:00
|
|
|
int (x2)(1);
|
2008-10-07 01:10:33 +08:00
|
|
|
|
|
|
|
void f() {
|
|
|
|
int x(1);
|
2008-12-18 00:19:15 +08:00
|
|
|
int (x2)(1);
|
2008-10-07 01:10:33 +08:00
|
|
|
for (int x(1);;) {}
|
|
|
|
}
|
2008-11-04 04:45:27 +08:00
|
|
|
|
|
|
|
class Y {
|
2010-04-10 03:03:51 +08:00
|
|
|
public: explicit Y(float);
|
2008-11-04 04:45:27 +08:00
|
|
|
};
|
|
|
|
|
2010-01-13 08:25:19 +08:00
|
|
|
class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
|
2008-11-04 04:45:27 +08:00
|
|
|
public:
|
2010-01-06 17:43:14 +08:00
|
|
|
explicit X(int); // expected-note{{candidate constructor}}
|
|
|
|
X(float, float, float); // expected-note{{candidate constructor}}
|
|
|
|
X(float, Y); // expected-note{{candidate constructor}}
|
2008-11-04 04:45:27 +08:00
|
|
|
};
|
|
|
|
|
2010-01-13 08:25:19 +08:00
|
|
|
class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
|
2008-11-04 04:45:27 +08:00
|
|
|
public:
|
2010-01-06 17:43:14 +08:00
|
|
|
Z(int); // expected-note{{candidate constructor}}
|
2008-11-04 04:45:27 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
X x1(5);
|
|
|
|
X x2(1.0, 3, 4.2);
|
2010-03-10 19:27:22 +08:00
|
|
|
X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'X'}}
|
2008-11-04 04:45:27 +08:00
|
|
|
Y y(1.0);
|
|
|
|
X x4(3.14, y);
|
|
|
|
|
2010-03-10 19:27:22 +08:00
|
|
|
Z z; // expected-error{{no matching constructor for initialization of 'Z'}}
|
2008-11-04 04:45:27 +08:00
|
|
|
}
|
2009-09-16 03:12:21 +08:00
|
|
|
|
|
|
|
struct Base {
|
2009-09-16 06:15:23 +08:00
|
|
|
operator int*() const;
|
2009-09-16 03:12:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Derived : Base {
|
2009-12-19 16:11:05 +08:00
|
|
|
operator int*(); // expected-note {{candidate function}}
|
2009-09-16 03:12:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void foo(const Derived cd, Derived d) {
|
2010-09-05 08:17:29 +08:00
|
|
|
int *pi = cd; // expected-error {{no viable conversion from 'const Derived' to 'int *'}}
|
2009-09-16 06:15:23 +08:00
|
|
|
int *ppi = d;
|
2009-09-16 03:12:21 +08:00
|
|
|
|
|
|
|
}
|