Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x |
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 | |
| 11 | struct B { |
| 12 | B(A); |
| 13 | }; |
| 14 | |
| 15 | int main () { |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 16 | B(10); // expected-error {{functional-style cast from 'int' to 'B' is not allowed}} |
| 17 | (B)10; // expected-error {{C-style cast from 'int' to 'B' is not allowed}} |
| 18 | static_cast<B>(10); // expected-error {{static_cast from 'int' to 'B' is not allowed}} \\ |
Fariborz Jahanian | 249cead | 2009-10-01 20:39:51 +0000 | [diff] [blame] | 19 | // expected-warning {{expression result unused}} |
| 20 | } |
| 21 | |
Douglas Gregor | b653c52 | 2009-11-06 01:14:41 +0000 | [diff] [blame] | 22 | template<class T> |
| 23 | struct X0 { |
| 24 | X0(const T &); |
| 25 | }; |
| 26 | |
| 27 | template<class T> |
| 28 | X0<T> make_X0(const T &Val) { |
| 29 | return X0<T>(Val); |
| 30 | } |
| 31 | |
| 32 | void test_X0() { |
Douglas Gregor | 60c93c9 | 2010-02-09 07:26:29 +0000 | [diff] [blame] | 33 | const char array[2] = { 'a', 'b' }; |
Douglas Gregor | b653c52 | 2009-11-06 01:14:41 +0000 | [diff] [blame] | 34 | make_X0(array); |
| 35 | } |
Douglas Gregor | 27591ff | 2009-11-06 05:48:00 +0000 | [diff] [blame] | 36 | |
| 37 | // PR5210 recovery |
| 38 | class C { |
| 39 | protected: |
| 40 | template <int> float* &f0(); // expected-note{{candidate}} |
| 41 | template <unsigned> float* &f0(); // expected-note{{candidate}} |
| 42 | |
| 43 | void f1() { |
| 44 | static_cast<float*>(f0<0>()); // expected-error{{ambiguous}} |
| 45 | } |
| 46 | }; |