blob: 9f27bb882e6672a254ad72949c268aae9f35a09e [file] [log] [blame]
Daniel Dunbar3573b2c2009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -fsyntax-only -verify
Nate Begemanc4e28e42008-01-25 05:34:48 +00002
Douglas Gregorc25bf6d2009-02-18 22:23:55 +00003//typedef __attribute__(( ext_vector_type(4) )) float float4;
4typedef float float4 __attribute__((vector_size(16)));
Nate Begemanc4e28e42008-01-25 05:34:48 +00005
6float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };
Douglas Gregorf603b472009-01-28 21:54:33 +00007
Douglas Gregorc25bf6d2009-02-18 22:23:55 +00008float4 foo2 = (float4){ 1.0, 2.0, 3.0, 4.0 , 5.0 }; // expected-warning{{excess elements in vector initializer}}
9
Douglas Gregorf603b472009-01-28 21:54:33 +000010float4 array[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
Daniel Dunbarc31911f2009-10-25 23:11:15 +000011int array_sizecheck[(sizeof(array) / sizeof(float4)) == 3 ? 1 : -1];
Douglas Gregorf603b472009-01-28 21:54:33 +000012
13float4 array2[2] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
Douglas Gregorc25bf6d2009-02-18 22:23:55 +000014 9.0 }; // expected-warning {{excess elements in array initializer}}
Douglas Gregorf603b472009-01-28 21:54:33 +000015
16float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0,
Douglas Gregorc25bf6d2009-02-18 22:23:55 +000017 9.0 }; // expected-warning {{excess elements in array initializer}}
Chris Lattner077fed52009-05-13 04:00:12 +000018
John Thompsonf3497ad2009-12-04 21:51:28 +000019// PR5650
20__attribute__((vector_size(16))) float f1(void) {
21 __attribute__((vector_size(16))) float vec = {0.0f, 0.0f, 0.0f};
22 return(vec);
23}
Chris Lattner077fed52009-05-13 04:00:12 +000024
John Thompsonf3497ad2009-12-04 21:51:28 +000025__attribute__((vector_size(16))) float f2(
26 __attribute__((vector_size(16))) float a1) {
27 return(a1);
Chris Lattner077fed52009-05-13 04:00:12 +000028}
Chris Lattnercb088462009-10-22 05:17:15 +000029
30
31
32// PR5265
33typedef float __attribute__((ext_vector_type (3))) float3;
Daniel Dunbarc31911f2009-10-25 23:11:15 +000034int test2[sizeof(float3) == sizeof(float4) ? 1 : -1];
Chris Lattnercb088462009-10-22 05:17:15 +000035
John McCall2c5695d2010-10-30 00:11:39 +000036// rdar://problem/8345836
37typedef long long __attribute__((vector_size(16))) longlong2;
38typedef short __attribute__((vector_size(16))) short8;
39typedef short __attribute__((vector_size(8))) short4;
40void test3() {
41 extern short8 test3_helper(void);
42 longlong2 arr1[2] = { test3_helper(), test3_helper() };
Stephen Hines6bcf27b2014-05-29 04:14:42 -070043 short4 arr2[2] = { test3_helper(), test3_helper() }; // expected-error 2 {{initializing 'short4' (vector of 4 'short' values) with an expression of incompatible type 'short8' (vector of 8 'short' values)}}
John McCall2c5695d2010-10-30 00:11:39 +000044}