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