xref: /llvm-project/clang/test/SemaCXX/altivec.cpp (revision 83ea47acd7116bf50274534ba9b3bd3035c01da6)
1 // RUN: %clang_cc1 -target-feature +altivec -flax-vector-conversions=none -triple powerpc-unknown-unknown -fcxx-exceptions -verify=expected,precxx17 %std_cxx98-14 %s
2 // RUN: %clang_cc1 -target-feature +altivec -flax-vector-conversions=none -triple powerpc-unknown-unknown -fcxx-exceptions -verify %std_cxx17- %s
3 
4 typedef int V4i __attribute__((vector_size(16)));
5 
test_vec_step(vector short arg1)6 void test_vec_step(vector short arg1) {
7   vector bool char vbc;
8   vector signed char vsc;
9   vector unsigned char vuc;
10   vector bool short vbs;
11   vector short vs;
12   vector unsigned short vus;
13   vector pixel vp;
14   vector bool int vbi;
15   vector int vi;
16   vector unsigned int vui;
17   vector float vf;
18 
19   vector int *pvi;
20 
21   int res1[vec_step(arg1) == 8 ? 1 : -1];
22   int res2[vec_step(vbc) == 16 ? 1 : -1];
23   int res3[vec_step(vsc) == 16 ? 1 : -1];
24   int res4[vec_step(vuc) == 16 ? 1 : -1];
25   int res5[vec_step(vbs) == 8 ? 1 : -1];
26   int res6[vec_step(vs) == 8 ? 1 : -1];
27   int res7[vec_step(vus) == 8 ? 1 : -1];
28   int res8[vec_step(vp) == 8 ? 1 : -1];
29   int res9[vec_step(vbi) == 4 ? 1 : -1];
30   int res10[vec_step(vi) == 4 ? 1 : -1];
31   int res11[vec_step(vui) == 4 ? 1 : -1];
32   int res12[vec_step(vf) == 4 ? 1 : -1];
33   int res13[vec_step(*pvi) == 4 ? 1 : -1];
34 }
35 
f(V4i a)36 void f(V4i a)
37 {
38 }
39 
test1()40 void test1()
41 {
42   V4i vGCC;
43   vector int vAltiVec;
44 
45   f(vAltiVec);
46   vGCC = vAltiVec;
47   bool res = vGCC > vAltiVec;
48   vAltiVec = 0 ? vGCC : vGCC;
49 }
50 
51 template<typename T>
template_f(T param)52 void template_f(T param) {
53   param++;
54 }
55 
test2()56 void test2()
57 {
58   vector int vi;
59   ++vi;
60   vi++;
61   --vi;
62   vi--;
63   vector float vf;
64   vf++;
65 
66   ++vi=vi; // precxx17-warning {{unsequenced}}
67   (++vi)[1]=1;
68   template_f(vi);
69 }
70 
71 namespace LValueToRValueConversions {
72   struct Struct {
73     float f();
74     int n();
75   };
76 
77   vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}}
78   vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}}
79 }
80 
f()81 void f() {
82   try {}
83   catch (vector pixel px) {}
84 };
85