2009-12-16 04:14:24 +08:00
// RUN: %clang_cc1 %s -fsyntax-only -verify
2008-01-25 13:34:48 +08:00
2009-02-19 06:23:55 +08:00
//typedef __attribute__(( ext_vector_type(4) )) float float4;
typedef float float4 __attribute__ ( ( vector_size ( 16 ) ) ) ;
2008-01-25 13:34:48 +08:00
float4 foo = ( float4 ) { 1.0 , 2.0 , 3.0 , 4.0 } ;
2009-01-29 05:54:33 +08:00
2009-02-19 06:23:55 +08:00
float4 foo2 = ( float4 ) { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 } ; // expected-warning{{excess elements in vector initializer}}
2009-01-29 05:54:33 +08:00
float4 array [ ] = { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 } ;
2009-10-26 07:11:15 +08:00
int array_sizecheck [ ( sizeof ( array ) / sizeof ( float4 ) ) = = 3 ? 1 : - 1 ] ;
2009-01-29 05:54:33 +08:00
float4 array2 [ 2 ] = { 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 ,
2009-02-19 06:23:55 +08:00
9.0 } ; // expected-warning {{excess elements in array initializer}}
2009-01-29 05:54:33 +08:00
float4 array3 [ 2 ] = { { 1.0 , 2.0 , 3.0 } , 5.0 , 6.0 , 7.0 , 8.0 ,
2009-02-19 06:23:55 +08:00
9.0 } ; // expected-warning {{excess elements in array initializer}}
2009-05-13 12:00:12 +08:00
2009-12-05 05:51:28 +08:00
// PR5650
__attribute__ ( ( vector_size ( 16 ) ) ) float f1 ( void ) {
__attribute__ ( ( vector_size ( 16 ) ) ) float vec = { 0.0f , 0.0f , 0.0f } ;
return ( vec ) ;
}
2009-05-13 12:00:12 +08:00
2009-12-05 05:51:28 +08:00
__attribute__ ( ( vector_size ( 16 ) ) ) float f2 (
__attribute__ ( ( vector_size ( 16 ) ) ) float a1 ) {
return ( a1 ) ;
2009-05-13 12:00:12 +08:00
}
2009-10-22 13:17:15 +08:00
// PR5265
typedef float __attribute__ ( ( ext_vector_type ( 3 ) ) ) float3 ;
2009-10-26 07:11:15 +08:00
int test2 [ sizeof ( float3 ) = = sizeof ( float4 ) ? 1 : - 1 ] ;
2009-10-22 13:17:15 +08:00
2010-10-30 08:11:39 +08:00
// rdar://problem/8345836
typedef long long __attribute__ ( ( vector_size ( 16 ) ) ) longlong2 ;
typedef short __attribute__ ( ( vector_size ( 16 ) ) ) short8 ;
typedef short __attribute__ ( ( vector_size ( 8 ) ) ) short4 ;
void test3 ( ) {
extern short8 test3_helper ( void ) ;
longlong2 arr1 [ 2 ] = { test3_helper ( ) , test3_helper ( ) } ;
2014-04-26 04:41:38 +08:00
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)}}
2010-10-30 08:11:39 +08:00
}