brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 81965a3 Raw
52 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -verify2 3//typedef __attribute__(( ext_vector_type(4) ))  float float4;4typedef float float4 __attribute__((vector_size(16)));5 6float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };7 8float4 foo2 = (float4){ 1.0, 2.0, 3.0, 4.0 , 5.0 }; // expected-warning{{excess elements in vector initializer}}9 10float4 array[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};11int array_sizecheck[(sizeof(array) / sizeof(float4)) == 3 ? 1 : -1];12 13float4 array2[2] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 14                     9.0 }; // expected-warning {{excess elements in array initializer}}15 16float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0,17                     9.0 }; // expected-warning {{excess elements in array initializer}}18 19// PR565020__attribute__((vector_size(16))) float f1(void) {21  __attribute__((vector_size(16))) float vec = {0.0f, 0.0f, 0.0f};22  return(vec);23}24 25__attribute__((vector_size(16))) float f2(26    __attribute__((vector_size(16))) float a1) {27  return(a1);28}29 30 31 32// PR526533typedef float __attribute__((ext_vector_type (3))) float3;34int test2[sizeof(float3) == sizeof(float4) ? 1 : -1];35 36typedef long long __attribute__((vector_size(16))) longlong2;37typedef short __attribute__((vector_size(16))) short8;38typedef short __attribute__((vector_size(8))) short4;39void test3(void) {40  extern short8 test3_helper(void);41  longlong2 arr1[2] = { test3_helper(), test3_helper() };42  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)}}43}44 45// GH5021646// These would previously crash when constant evaluating the initializers.47typedef double float64x1_t __attribute__((vector_size(8)));48float64x1_t arg1 = (float64x1_t)0x3fedf9d4343c7c80; // okay49 50typedef float float32x1_t __attribute__((vector_size(4)));51float32x1_t arg2 = (float32x1_t)0x3fedf9d4; // okay52