xref: /minix3/external/bsd/llvm/dist/clang/test/Sema/altivec-init.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -faltivec -verify -pedantic -fsyntax-only
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc typedef int v4 __attribute((vector_size(16)));
4*f4a2713aSLionel Sambuc typedef short v8 __attribute((vector_size(16)));
5*f4a2713aSLionel Sambuc 
foo(void)6*f4a2713aSLionel Sambuc v8 foo(void) {
7*f4a2713aSLionel Sambuc   v8 a;
8*f4a2713aSLionel Sambuc   v4 b;
9*f4a2713aSLionel Sambuc   a = (v8){4, 2};
10*f4a2713aSLionel Sambuc   b = (v4)(5, 6, 7, 8, 9); // expected-warning {{excess elements in vector initializer}}
11*f4a2713aSLionel Sambuc   b = (v4)(5, 6, 8, 8.0f);
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc   vector int vi;
14*f4a2713aSLionel Sambuc   vi = (vector int)(1);
15*f4a2713aSLionel Sambuc   vi = (vector int)(1, 2);          // expected-error {{number of elements must be either one or match the size of the vector}}
16*f4a2713aSLionel Sambuc   vi = (vector int)(1, 2, 3, 4);
17*f4a2713aSLionel Sambuc   vi = (vector int)(1, 2, 3, 4, 5); // expected-warning {{excess elements in vector initializer}}
18*f4a2713aSLionel Sambuc   vi = (vector int){1};
19*f4a2713aSLionel Sambuc   vi = (vector int){1, 2};
20*f4a2713aSLionel Sambuc   vi = (vector int){1, 2, 3, 4, 5}; // expected-warning {{excess elements in vector initializer}}
21*f4a2713aSLionel Sambuc   vector float vf;
22*f4a2713aSLionel Sambuc   vf = (vector float)(1.0);
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc   return (v8){0, 1, 2, 3, 1, 2, 3, 4};
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc   // FIXME: test that (type)(fn)(args) still works with -faltivec
27*f4a2713aSLionel Sambuc   // FIXME: test that c++ overloaded commas still work -faltivec
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc 
f(v4 a)30*f4a2713aSLionel Sambuc void __attribute__((__overloadable__)) f(v4 a)
31*f4a2713aSLionel Sambuc {
32*f4a2713aSLionel Sambuc }
33*f4a2713aSLionel Sambuc 
f(int a)34*f4a2713aSLionel Sambuc void __attribute__((__overloadable__)) f(int a)
35*f4a2713aSLionel Sambuc {
36*f4a2713aSLionel Sambuc }
37*f4a2713aSLionel Sambuc 
test()38*f4a2713aSLionel Sambuc void test()
39*f4a2713aSLionel Sambuc {
40*f4a2713aSLionel Sambuc   v4 vGCC;
41*f4a2713aSLionel Sambuc   vector int vAltiVec;
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc   f(vAltiVec);
44*f4a2713aSLionel Sambuc   vGCC = vAltiVec;
45*f4a2713aSLionel Sambuc   int res = vGCC > vAltiVec;
46*f4a2713aSLionel Sambuc   vAltiVec = 0 ? vGCC : vGCC;
47*f4a2713aSLionel Sambuc }
48