blob: 75002fa585b89310824811dd5fffa6e423792b9a [file] [log] [blame]
Charles Lie7cbb3e2015-11-17 20:25:05 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
Douglas Gregor26bee0b2008-10-31 16:23:19 +00005class Z { };
6
7class Y {
8public:
9 Y(const Z&);
10};
11
12class X {
13public:
14 X(int);
15 X(const Y&);
16};
17
Douglas Gregore254f902009-02-04 00:32:51 +000018void f(X); // expected-note{{candidate function}}
Douglas Gregor26bee0b2008-10-31 16:23:19 +000019
20void g(short s, Y y, Z z) {
21 f(s);
22 f(1.0f);
23 f(y);
Douglas Gregore254f902009-02-04 00:32:51 +000024 f(z); // expected-error{{no matching function}}
Douglas Gregor26bee0b2008-10-31 16:23:19 +000025}
26
Douglas Gregorcba844d2009-01-14 18:02:48 +000027
28class FromShort {
29public:
30 FromShort(short s);
31};
32
John McCalle1ac8d12010-01-13 00:25:19 +000033class FromShortExplicitly { // expected-note{{candidate constructor (the implicit copy constructor)}}
Charles Lie7cbb3e2015-11-17 20:25:05 +000034#if __cplusplus >= 201103L // C++11 or later
35// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
36#endif
37
Douglas Gregorcba844d2009-01-14 18:02:48 +000038public:
39 explicit FromShortExplicitly(short s);
40};
41
42void explicit_constructor(short s) {
43 FromShort fs1(s);
44 FromShort fs2 = s;
45 FromShortExplicitly fse1(s);
Douglas Gregora4b592a2009-12-19 03:01:41 +000046 FromShortExplicitly fse2 = s; // expected-error{{no viable conversion}}
Douglas Gregorcba844d2009-01-14 18:02:48 +000047}
Douglas Gregor2094c5e2009-11-20 22:05:53 +000048
49// PR5519
50struct X1 { X1(const char&); };
51void x1(X1);
52void y1() {
53 x1(1);
54}