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
main()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 // expected-warning {{expression result unused}}
21 }
22
23 template<class T>
24 struct X0 {
25 X0(const T &);
26 };
27
28 template<class T>
make_X0(const T & Val)29 X0<T> make_X0(const T &Val) {
30 return X0<T>(Val);
31 }
32
test_X0()33 void test_X0() {
34 const char array[2] = { 'a', 'b' };
35 make_X0(array);
36 }
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
f1()44 void f1() {
45 static_cast<float*>(f0<0>()); // expected-error{{ambiguous}}
46 }
47 };
48
intToPointer1(short s)49 void *intToPointer1(short s) {
50 return (void*)s; // expected-warning{{cast to 'void *' from smaller integer type 'short'}}
51 }
52
intToPointer2(short s)53 void *intToPointer2(short s) {
54 return reinterpret_cast<void*>(s);
55 }
56
intToPointer3(bool b)57 void *intToPointer3(bool b) {
58 return (void*)b;
59 }
60
intToPointer4()61 void *intToPointer4() {
62 return (void*)(3 + 7);
63 }
64
intToPointer5(long l)65 void *intToPointer5(long l) {
66 return (void*)l;
67 }
68