blob: 1c20450a6d015f677d8e19bcd9fd722a3df1ef49 [file] [log] [blame]
Eric Christopher758aad72017-03-21 22:06:18 +00001// RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -target-feature +altivec -verify -pedantic -fsyntax-only
Nate Begeman5ec4b312009-08-10 23:49:36 +00002
3typedef int v4 __attribute((vector_size(16)));
4typedef short v8 __attribute((vector_size(16)));
5
6v8 foo(void) {
7 v8 a;
8 v4 b;
John Thompson359675d2010-04-20 05:01:46 +00009 a = (v8){4, 2};
Nate Begeman5ec4b312009-08-10 23:49:36 +000010 b = (v4)(5, 6, 7, 8, 9); // expected-warning {{excess elements in vector initializer}}
11 b = (v4)(5, 6, 8, 8.0f);
Anton Yartsev28ccef72011-03-27 09:32:40 +000012
13 vector int vi;
14 vi = (vector int)(1);
15 vi = (vector int)(1, 2); // expected-error {{number of elements must be either one or match the size of the vector}}
16 vi = (vector int)(1, 2, 3, 4);
17 vi = (vector int)(1, 2, 3, 4, 5); // expected-warning {{excess elements in vector initializer}}
18 vi = (vector int){1};
19 vi = (vector int){1, 2};
20 vi = (vector int){1, 2, 3, 4, 5}; // expected-warning {{excess elements in vector initializer}}
21 vector float vf;
22 vf = (vector float)(1.0);
23
Nate Begeman5ec4b312009-08-10 23:49:36 +000024 return (v8){0, 1, 2, 3, 1, 2, 3, 4};
25
Eric Christopher758aad72017-03-21 22:06:18 +000026 // FIXME: test that (type)(fn)(args) still works with -maltivec
27 // FIXME: test that c++ overloaded commas still work -maltivec
Nate Begeman5ec4b312009-08-10 23:49:36 +000028}
Douglas Gregor59e8b3b2010-08-06 10:14:59 +000029
30void __attribute__((__overloadable__)) f(v4 a)
31{
32}
33
34void __attribute__((__overloadable__)) f(int a)
35{
36}
37
38void test()
39{
40 v4 vGCC;
41 vector int vAltiVec;
42
43 f(vAltiVec);
44 vGCC = vAltiVec;
Anton Yartsev3f8f2882010-11-18 03:19:30 +000045 int res = vGCC > vAltiVec;
Douglas Gregor59e8b3b2010-08-06 10:14:59 +000046 vAltiVec = 0 ? vGCC : vGCC;
47}