blob: 9dac6c7114da0b760a545138b2e06cdc25305fda [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc %s -fsyntax-only -verify
Nate Begemand47d4f52008-01-25 05:34:48 +00002
Douglas Gregor7c53ca62009-02-18 22:23:55 +00003//typedef __attribute__(( ext_vector_type(4) )) float float4;
4typedef float float4 __attribute__((vector_size(16)));
Nate Begemand47d4f52008-01-25 05:34:48 +00005
6float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };
Douglas Gregor4c678342009-01-28 21:54:33 +00007
Douglas Gregor7c53ca62009-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 Gregor4c678342009-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 Dunbar9e4e2d12009-10-25 23:11:15 +000011int array_sizecheck[(sizeof(array) / sizeof(float4)) == 3 ? 1 : -1];
Douglas Gregor4c678342009-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 Gregor7c53ca62009-02-18 22:23:55 +000014 9.0 }; // expected-warning {{excess elements in array initializer}}
Douglas Gregor4c678342009-01-28 21:54:33 +000015
16float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0,
Douglas Gregor7c53ca62009-02-18 22:23:55 +000017 9.0 }; // expected-warning {{excess elements in array initializer}}
Chris Lattner2db15bd2009-05-13 04:00:12 +000018
19
20// rdar://6881069
21__attribute__((vector_size(16))) // expected-error {{unsupported type 'float (void)' for vector_size attribute, please use on typedef}}
22float f1(void) {
23}
Chris Lattner9fcfe922009-10-22 05:17:15 +000024
25
26
27// PR5265
28typedef float __attribute__((ext_vector_type (3))) float3;
Daniel Dunbar9e4e2d12009-10-25 23:11:15 +000029int test2[sizeof(float3) == sizeof(float4) ? 1 : -1];
Chris Lattner9fcfe922009-10-22 05:17:15 +000030