Charles Li | e7cbb3e | 2015-11-17 20:25:05 +0000 | [diff] [blame] | 1 | // 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 Gregor | 26bee0b | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 5 | class Z { }; |
| 6 | |
| 7 | class Y { |
| 8 | public: |
| 9 | Y(const Z&); |
| 10 | }; |
| 11 | |
| 12 | class X { |
| 13 | public: |
| 14 | X(int); |
| 15 | X(const Y&); |
| 16 | }; |
| 17 | |
Douglas Gregor | e254f90 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 18 | void f(X); // expected-note{{candidate function}} |
Douglas Gregor | 26bee0b | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 19 | |
| 20 | void g(short s, Y y, Z z) { |
| 21 | f(s); |
| 22 | f(1.0f); |
| 23 | f(y); |
Douglas Gregor | e254f90 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 24 | f(z); // expected-error{{no matching function}} |
Douglas Gregor | 26bee0b | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 25 | } |
| 26 | |
Douglas Gregor | cba844d | 2009-01-14 18:02:48 +0000 | [diff] [blame] | 27 | |
| 28 | class FromShort { |
| 29 | public: |
| 30 | FromShort(short s); |
| 31 | }; |
| 32 | |
John McCall | e1ac8d1 | 2010-01-13 00:25:19 +0000 | [diff] [blame] | 33 | class FromShortExplicitly { // expected-note{{candidate constructor (the implicit copy constructor)}} |
Charles Li | e7cbb3e | 2015-11-17 20:25:05 +0000 | [diff] [blame] | 34 | #if __cplusplus >= 201103L // C++11 or later |
| 35 | // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} |
| 36 | #endif |
| 37 | |
Douglas Gregor | cba844d | 2009-01-14 18:02:48 +0000 | [diff] [blame] | 38 | public: |
| 39 | explicit FromShortExplicitly(short s); |
| 40 | }; |
| 41 | |
| 42 | void explicit_constructor(short s) { |
| 43 | FromShort fs1(s); |
| 44 | FromShort fs2 = s; |
| 45 | FromShortExplicitly fse1(s); |
Douglas Gregor | a4b592a | 2009-12-19 03:01:41 +0000 | [diff] [blame] | 46 | FromShortExplicitly fse2 = s; // expected-error{{no viable conversion}} |
Douglas Gregor | cba844d | 2009-01-14 18:02:48 +0000 | [diff] [blame] | 47 | } |
Douglas Gregor | 2094c5e | 2009-11-20 22:05:53 +0000 | [diff] [blame] | 48 | |
| 49 | // PR5519 |
| 50 | struct X1 { X1(const char&); }; |
| 51 | void x1(X1); |
| 52 | void y1() { |
| 53 | x1(1); |
| 54 | } |