1 | // RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -verify %s -std=c++11 |
2 | |
3 | struct R { |
4 | R(int); |
5 | }; |
6 | |
7 | struct A { |
8 | A(R); |
9 | }; |
10 | |
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}} |
13 | B(A); // expected-note 3 {{candidate constructor not viable}} |
14 | }; |
15 | |
16 | int main () { |
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'}} |
20 | } |
21 | |
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() { |
33 | const char array[2] = { 'a', 'b' }; |
34 | make_X0(array); |
35 | } |
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 | }; |
47 | |
48 | void *intToPointer1(short s) { |
49 | return (void*)s; // expected-warning{{cast to 'void *' from smaller integer type 'short'}} |
50 | } |
51 | |
52 | void *intToPointer2(short s) { |
53 | return reinterpret_cast<void*>(s); |
54 | } |
55 | |
56 | void *intToPointer3(bool b) { |
57 | return (void*)b; |
58 | } |
59 | |
60 | void *intToPointer4() { |
61 | return (void*)(3 + 7); |
62 | } |
63 | |
64 | void *intToPointer5(long l) { |
65 | return (void*)l; |
66 | } |
67 | |
68 | struct AmbiguousCast { |
69 | operator int(); // expected-note {{candidate function}} |
70 | operator unsigned int(); // expected-note {{candidate function}} |
71 | }; |
72 | long long AmbiguousCastFunc(AmbiguousCast& a) { |
73 | return static_cast<long long>(a); // expected-error {{ambiguous conversion for static_cast from 'AmbiguousCast' to 'long long'}} |
74 | } |
75 | |
76 | namespace PR16680 { |
77 | void f(int (*__pf)()); |
78 | int g() { |
79 | f(reinterpret_cast<int>(0.0f)); // expected-error {{reinterpret_cast from 'float' to 'int' is not allowed}} |
80 | } |
81 | } |
82 | |