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