2015-11-18 04:25:05 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
|
|
|
|
2008-11-01 00:23:19 +08:00
|
|
|
class Z { };
|
|
|
|
|
|
|
|
class Y {
|
|
|
|
public:
|
|
|
|
Y(const Z&);
|
|
|
|
};
|
|
|
|
|
|
|
|
class X {
|
|
|
|
public:
|
|
|
|
X(int);
|
|
|
|
X(const Y&);
|
|
|
|
};
|
|
|
|
|
2009-02-04 08:32:51 +08:00
|
|
|
void f(X); // expected-note{{candidate function}}
|
2008-11-01 00:23:19 +08:00
|
|
|
|
|
|
|
void g(short s, Y y, Z z) {
|
|
|
|
f(s);
|
|
|
|
f(1.0f);
|
|
|
|
f(y);
|
2009-02-04 08:32:51 +08:00
|
|
|
f(z); // expected-error{{no matching function}}
|
2008-11-01 00:23:19 +08:00
|
|
|
}
|
|
|
|
|
2009-01-15 02:02:48 +08:00
|
|
|
|
|
|
|
class FromShort {
|
|
|
|
public:
|
|
|
|
FromShort(short s);
|
|
|
|
};
|
|
|
|
|
2010-01-13 08:25:19 +08:00
|
|
|
class FromShortExplicitly { // expected-note{{candidate constructor (the implicit copy constructor)}}
|
2015-11-18 04:25:05 +08:00
|
|
|
#if __cplusplus >= 201103L // C++11 or later
|
|
|
|
// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
|
|
|
|
#endif
|
|
|
|
|
2009-01-15 02:02:48 +08:00
|
|
|
public:
|
2020-01-10 04:27:48 +08:00
|
|
|
explicit FromShortExplicitly(short s); // expected-note {{explicit constructor is not a candidate}}
|
2009-01-15 02:02:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void explicit_constructor(short s) {
|
|
|
|
FromShort fs1(s);
|
|
|
|
FromShort fs2 = s;
|
|
|
|
FromShortExplicitly fse1(s);
|
2009-12-19 11:01:41 +08:00
|
|
|
FromShortExplicitly fse2 = s; // expected-error{{no viable conversion}}
|
2009-01-15 02:02:48 +08:00
|
|
|
}
|
2009-11-21 06:05:53 +08:00
|
|
|
|
|
|
|
// PR5519
|
|
|
|
struct X1 { X1(const char&); };
|
|
|
|
void x1(X1);
|
|
|
|
void y1() {
|
|
|
|
x1(1);
|
|
|
|
}
|