[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / SemaCXX / cast-conversion.cpp
blobe48d918f889bcbed6b50a699368e7783418fc5d9
1 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -verify %s -std=c++11 -Wno-unused
3 struct R {
4 R(int);
5 };
7 struct A {
8 A(R);
9 };
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}}
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'}}
22 template<class T>
23 struct X0 {
24 X0(const T &);
27 template<class T>
28 X0<T> make_X0(const T &Val) {
29 return X0<T>(Val);
32 void test_X0() {
33 const char array[2] = { 'a', 'b' };
34 make_X0(array);
37 // PR5210 recovery
38 class C {
39 protected:
40 template <int> float* &f0(); // expected-note{{candidate}}
41 template <unsigned> float* &f0(); // expected-note{{candidate}}
43 void f1() {
44 static_cast<float*>(f0<0>()); // expected-error{{ambiguous}}
48 void *intToPointer1(short s) {
49 return (void*)s; // expected-warning{{cast to 'void *' from smaller integer type 'short'}}
52 void *intToPointer2(short s) {
53 return reinterpret_cast<void*>(s);
56 void *intToPointer3(bool b) {
57 return (void*)b;
60 void *intToPointer4() {
61 return (void*)(3 + 7);
64 void *intToPointer5(long l) {
65 return (void*)l;
68 struct AmbiguousCast {
69 operator int(); // expected-note {{candidate function}}
70 operator unsigned int(); // expected-note {{candidate function}}
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'}}
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}}