blob: 1688e51e73fdf58c299e96590cc1e28fc0cc7861 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor60d62c22008-10-31 16:23:19 +00002class Z { };
3
4class Y {
5public:
6 Y(const Z&);
7};
8
9class X {
10public:
11 X(int);
12 X(const Y&);
13};
14
Douglas Gregorfa047642009-02-04 00:32:51 +000015void f(X); // expected-note{{candidate function}}
Douglas Gregor60d62c22008-10-31 16:23:19 +000016
17void g(short s, Y y, Z z) {
18 f(s);
19 f(1.0f);
20 f(y);
Douglas Gregorfa047642009-02-04 00:32:51 +000021 f(z); // expected-error{{no matching function}}
Douglas Gregor60d62c22008-10-31 16:23:19 +000022}
23
Douglas Gregorbf985f12009-01-14 18:02:48 +000024
25class FromShort {
26public:
27 FromShort(short s);
28};
29
John McCall220ccbf2010-01-13 00:25:19 +000030class FromShortExplicitly { // expected-note{{candidate constructor (the implicit copy constructor)}}
Douglas Gregorbf985f12009-01-14 18:02:48 +000031public:
32 explicit FromShortExplicitly(short s);
33};
34
35void explicit_constructor(short s) {
36 FromShort fs1(s);
37 FromShort fs2 = s;
38 FromShortExplicitly fse1(s);
Douglas Gregor7abfbdb2009-12-19 03:01:41 +000039 FromShortExplicitly fse2 = s; // expected-error{{no viable conversion}}
Douglas Gregorbf985f12009-01-14 18:02:48 +000040}
Douglas Gregoreeb7fd02009-11-20 22:05:53 +000041
42// PR5519
43struct X1 { X1(const char&); };
44void x1(X1);
45void y1() {
46 x1(1);
47}