blob: a7899c75e4dc07571a34e3bee5e9b22213ebc2dc [file] [log] [blame]
Daniel Dunbar3573b2c2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Argiris Kirtzidis9e55d462008-10-06 17:10:33 +00002
3int x(1);
Argiris Kirtzidis0941ff42008-10-07 10:21:57 +00004int (x2)(1);
Argiris Kirtzidis9e55d462008-10-06 17:10:33 +00005
6void f() {
7 int x(1);
Douglas Gregor9dd88c72008-12-17 16:19:15 +00008 int (x2)(1);
Argiris Kirtzidis9e55d462008-10-06 17:10:33 +00009 for (int x(1);;) {}
10}
Douglas Gregor5870a952008-11-03 20:45:27 +000011
12class Y {
John McCall4f4bd832010-04-09 19:03:51 +000013public: explicit Y(float);
Douglas Gregor5870a952008-11-03 20:45:27 +000014};
15
John McCallec29a812010-01-13 00:25:19 +000016class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
Douglas Gregor5870a952008-11-03 20:45:27 +000017public:
John McCall84b499e2010-01-06 09:43:14 +000018 explicit X(int); // expected-note{{candidate constructor}}
19 X(float, float, float); // expected-note{{candidate constructor}}
20 X(float, Y); // expected-note{{candidate constructor}}
Douglas Gregor5870a952008-11-03 20:45:27 +000021};
22
John McCallec29a812010-01-13 00:25:19 +000023class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
Douglas Gregor5870a952008-11-03 20:45:27 +000024public:
John McCall84b499e2010-01-06 09:43:14 +000025 Z(int); // expected-note{{candidate constructor}}
Douglas Gregor5870a952008-11-03 20:45:27 +000026};
27
28void g() {
29 X x1(5);
30 X x2(1.0, 3, 4.2);
John McCall98624352010-03-10 11:27:22 +000031 X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'X'}}
Douglas Gregor5870a952008-11-03 20:45:27 +000032 Y y(1.0);
33 X x4(3.14, y);
34
John McCall98624352010-03-10 11:27:22 +000035 Z z; // expected-error{{no matching constructor for initialization of 'Z'}}
Douglas Gregor5870a952008-11-03 20:45:27 +000036}
Fariborz Jahanian3fa04992009-09-15 19:12:21 +000037
38struct Base {
Fariborz Jahanian97eecea2009-09-15 22:15:23 +000039 operator int*() const;
Fariborz Jahanian3fa04992009-09-15 19:12:21 +000040};
41
42struct Derived : Base {
Eli Friedmand9391422009-12-19 08:11:05 +000043 operator int*(); // expected-note {{candidate function}}
Fariborz Jahanian3fa04992009-09-15 19:12:21 +000044};
45
46void foo(const Derived cd, Derived d) {
Chris Lattnerda004db2010-09-05 00:17:29 +000047 int *pi = cd; // expected-error {{no viable conversion from 'const Derived' to 'int *'}}
Fariborz Jahanian97eecea2009-09-15 22:15:23 +000048 int *ppi = d;
Fariborz Jahanian3fa04992009-09-15 19:12:21 +000049
50}