xref: /llvm-project/clang/test/Parser/lax-conv.cpp (revision 87a6865d2c8eba802a7e9f42fa8b6ac1edd0664e)
1 // RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -target-cpu pwr8 -fsyntax-only -verify=expected,nonaix %s
2 // RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -target-cpu pwr8 -fsyntax-only -verify=expected,novsx %s
3 // RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -target-feature +vsx -target-cpu pwr8 -fsyntax-only -verify=expected,aix %s
4 
5 vector bool short vbs;
6 vector signed short vss;
7 vector unsigned short vus;
8 vector bool int vbi;
9 vector signed int vsi;
10 vector unsigned int vui;
11 vector bool long long vbl;
12 vector signed long long vsl;
13 vector unsigned long long vul;
14 vector bool char vbc;
15 vector signed char vsc;
16 vector unsigned char vuc;
17 vector pixel vp;
18 
19 void dummy(vector unsigned int a);
test(vector unsigned char a,vector unsigned char b)20 template <typename VEC> VEC __attribute__((noinline)) test(vector unsigned char a, vector unsigned char b) {
21     return (VEC)(a * b);
22 }
test1(vector unsigned char RetImplicitConv)23 vector unsigned int test1(vector unsigned char RetImplicitConv) {
24   return RetImplicitConv; // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
25 }
test2(vector unsigned char RetImplicitConvAddConst)26 vector unsigned int test2(vector unsigned char RetImplicitConvAddConst) {
27   return RetImplicitConvAddConst + 5; // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
28 }
test3(vector unsigned char RetExplicitConv)29 vector unsigned int test3(vector unsigned char RetExplicitConv) {
30   return (vector unsigned int)RetExplicitConv;
31 }
test4(vector unsigned char RetExplicitConvAddConst)32 vector unsigned int test4(vector unsigned char RetExplicitConvAddConst) {
33   return (vector unsigned int)RetExplicitConvAddConst + 5;
34 }
test5(vector unsigned char RetImplicitConvAddSame1,vector unsigned char RetImplicitConvAddSame2)35 vector unsigned int test5(vector unsigned char RetImplicitConvAddSame1,
36                           vector unsigned char RetImplicitConvAddSame2) {
37   return RetImplicitConvAddSame1 + RetImplicitConvAddSame2; // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
38 }
test6(vector unsigned char RetExplicitConvAddSame1,vector unsigned char RetExplicitConvAddSame2)39 vector unsigned int test6(vector unsigned char RetExplicitConvAddSame1,
40                           vector unsigned char RetExplicitConvAddSame2) {
41   return (vector unsigned int)RetExplicitConvAddSame1 +
42          (vector unsigned int)RetExplicitConvAddSame2;
43 }
test7(vector unsigned char RetExplicitConvAddSame1Full,vector unsigned char RetExplicitConvAddSame2Full)44 vector unsigned int test7(vector unsigned char RetExplicitConvAddSame1Full,
45                           vector unsigned char RetExplicitConvAddSame2Full) {
46   return (vector unsigned int)(RetExplicitConvAddSame1Full +
47                                RetExplicitConvAddSame2Full);
48 }
test8(vector unsigned char a,vector unsigned char b)49 vector unsigned char test8(vector unsigned char a, vector unsigned char b) {
50     return test<vector unsigned char>(a, b);
51 }
52 
test9(vector unsigned char a,vector unsigned char b)53 vector unsigned long long test9(vector unsigned char a, vector unsigned char b) {
54     return test<vector unsigned long long>(a, b);
55 }
test1a(vector unsigned char ArgImplicitConv)56 void test1a(vector unsigned char ArgImplicitConv) {
57   return dummy(ArgImplicitConv); // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
58 }
test2a(vector unsigned char ArgImplicitConvAddConst)59 void test2a(vector unsigned char ArgImplicitConvAddConst) {
60   return dummy(ArgImplicitConvAddConst + 5); // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
61 }
test3a(vector unsigned char ArgExplicitConv)62 void test3a(vector unsigned char ArgExplicitConv) {
63   return dummy((vector unsigned int)ArgExplicitConv);
64 }
test4a(vector unsigned char ArgExplicitConvAddConst)65 void test4a(vector unsigned char ArgExplicitConvAddConst) {
66   return dummy((vector unsigned int)ArgExplicitConvAddConst + 5);
67 }
test5a(vector unsigned char ArgImplicitConvAddSame1,vector unsigned char ArgImplicitConvAddSame2)68 void test5a(vector unsigned char ArgImplicitConvAddSame1,
69             vector unsigned char ArgImplicitConvAddSame2) {
70   return dummy(ArgImplicitConvAddSame1 + ArgImplicitConvAddSame2); // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
71 }
test6a(vector unsigned char ArgExplicitConvAddSame1,vector unsigned char ArgExplicitConvAddSame2)72 void test6a(vector unsigned char ArgExplicitConvAddSame1,
73             vector unsigned char ArgExplicitConvAddSame2) {
74   return dummy((vector unsigned int)ArgExplicitConvAddSame1 +
75                (vector unsigned int)ArgExplicitConvAddSame2);
76 }
test7a(vector unsigned char ArgExplicitConvAddSame1Full,vector unsigned char ArgExplicitConvAddSame2Full)77 void test7a(vector unsigned char ArgExplicitConvAddSame1Full,
78             vector unsigned char ArgExplicitConvAddSame2Full) {
79   return dummy((vector unsigned int)(ArgExplicitConvAddSame1Full +
80                                      ArgExplicitConvAddSame2Full));
81 }
test_bool_compat(void)82 void test_bool_compat(void) {
83   vbs = vss; // expected-warning {{implicit conversion between vector types (''__vector short' (vector of 8 'short' values)' and ''__vector __bool unsigned short' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
84   vbs = vus; // expected-warning {{implicit conversion between vector types (''__vector unsigned short' (vector of 8 'unsigned short' values)' and ''__vector __bool unsigned short' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
85 
86   vbi = vsi; // expected-warning {{implicit conversion between vector types (''__vector int' (vector of 4 'int' values)' and ''__vector __bool unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
87   vbi = vui; // expected-warning {{implicit conversion between vector types (''__vector unsigned int' (vector of 4 'unsigned int' values)' and ''__vector __bool unsigned int' (vector of 4 'unsigned int' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
88 
89   vbl = vsl; // expected-warning {{implicit conversion between vector types (''__vector long long' (vector of 2 'long long' values)' and ''__vector __bool unsigned long long' (vector of 2 'unsigned long long' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
90   vbl = vul; // expected-warning {{implicit conversion between vector types (''__vector unsigned long long' (vector of 2 'unsigned long long' values)' and ''__vector __bool unsigned long long' (vector of 2 'unsigned long long' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
91 
92   vbc = vsc; // expected-warning {{implicit conversion between vector types (''__vector signed char' (vector of 16 'signed char' values)' and ''__vector __bool unsigned char' (vector of 16 'unsigned char' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
93   vbc = vuc; // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector __bool unsigned char' (vector of 16 'unsigned char' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
94 }
95 
test_pixel_compat(void)96 void test_pixel_compat(void) {
97   vp = vbs; // expected-warning {{implicit conversion between vector types (''__vector __bool unsigned short' (vector of 8 'unsigned short' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
98   vp = vss; // expected-warning {{implicit conversion between vector types (''__vector short' (vector of 8 'short' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
99   vp = vus; // expected-warning {{implicit conversion between vector types (''__vector unsigned short' (vector of 8 'unsigned short' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
100 
101   vp = vbi; // expected-warning {{implicit conversion between vector types (''__vector __bool unsigned int' (vector of 4 'unsigned int' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
102   vp = vsi; // expected-warning {{implicit conversion between vector types (''__vector int' (vector of 4 'int' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
103   vp = vui; // expected-warning {{implicit conversion between vector types (''__vector unsigned int' (vector of 4 'unsigned int' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
104 
105   vp = vbl; // expected-warning {{implicit conversion between vector types (''__vector __bool unsigned long long' (vector of 2 'unsigned long long' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
106   vp = vsl; // expected-warning {{implicit conversion between vector types (''__vector long long' (vector of 2 'long long' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
107   vp = vul; // expected-warning {{implicit conversion between vector types (''__vector unsigned long long' (vector of 2 'unsigned long long' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
108 
109   vp = vbc; // expected-warning {{implicit conversion between vector types (''__vector __bool unsigned char' (vector of 16 'unsigned char' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
110   vp = vsc; // expected-warning {{implicit conversion between vector types (''__vector signed char' (vector of 16 'signed char' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
111   vp = vuc; // expected-warning {{implicit conversion between vector types (''__vector unsigned char' (vector of 16 'unsigned char' values)' and ''__vector __pixel ' (vector of 8 'unsigned short' values)') is deprecated; in the future, the behavior implied by '-fno-lax-vector-conversions' will be the default}}
112 }
113