Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 |
Fariborz Jahanian | 249cead | 2009-10-01 20:39:51 +0000 | [diff] [blame] | 2 | |
| 3 | struct R { |
| 4 | R(int); |
| 5 | }; |
| 6 | |
| 7 | struct A { |
| 8 | A(R); |
| 9 | }; |
| 10 | |
Sebastian Redl | 85ea7aa | 2011-08-30 19:58:05 +0000 | [diff] [blame] | 11 | struct B { // expected-note 3 {{candidate constructor (the implicit copy constructor) not viable}} \ |
| 12 | expected-note 3 {{candidate constructor (the implicit move constructor) not viable}} |
John McCall | 79ab2c8 | 2011-02-14 18:34:10 +0000 | [diff] [blame] | 13 | B(A); // expected-note 3 {{candidate constructor not viable}} |
Fariborz Jahanian | 249cead | 2009-10-01 20:39:51 +0000 | [diff] [blame] | 14 | }; |
| 15 | |
| 16 | int main () { |
John McCall | 79ab2c8 | 2011-02-14 18:34:10 +0000 | [diff] [blame] | 17 | B(10); // expected-error {{no matching conversion for functional-style cast from 'int' to 'B'}} |
| 18 | (B)10; // expected-error {{no matching conversion for C-style cast from 'int' to 'B'}} |
| 19 | static_cast<B>(10); // expected-error {{no matching conversion for static_cast from 'int' to 'B'}} \\ |
Argyrios Kyrtzidis | 1b2ad2f | 2010-09-19 23:03:35 +0000 | [diff] [blame] | 20 | // expected-warning {{expression result unused}} |
Fariborz Jahanian | 249cead | 2009-10-01 20:39:51 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Douglas Gregor | b653c52 | 2009-11-06 01:14:41 +0000 | [diff] [blame] | 23 | template<class T> |
| 24 | struct X0 { |
| 25 | X0(const T &); |
| 26 | }; |
| 27 | |
| 28 | template<class T> |
| 29 | X0<T> make_X0(const T &Val) { |
| 30 | return X0<T>(Val); |
| 31 | } |
| 32 | |
| 33 | void test_X0() { |
Douglas Gregor | 60c93c9 | 2010-02-09 07:26:29 +0000 | [diff] [blame] | 34 | const char array[2] = { 'a', 'b' }; |
Douglas Gregor | b653c52 | 2009-11-06 01:14:41 +0000 | [diff] [blame] | 35 | make_X0(array); |
| 36 | } |
Douglas Gregor | 27591ff | 2009-11-06 05:48:00 +0000 | [diff] [blame] | 37 | |
| 38 | // PR5210 recovery |
| 39 | class C { |
| 40 | protected: |
| 41 | template <int> float* &f0(); // expected-note{{candidate}} |
| 42 | template <unsigned> float* &f0(); // expected-note{{candidate}} |
| 43 | |
| 44 | void f1() { |
| 45 | static_cast<float*>(f0<0>()); // expected-error{{ambiguous}} |
| 46 | } |
| 47 | }; |