1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions %s
2 
3 typedef __attribute__(( ext_vector_type(2) )) float float2;
4 typedef __attribute__(( ext_vector_type(4) )) int int4;
5 typedef __attribute__(( ext_vector_type(8) )) short short8;
6 typedef __attribute__(( ext_vector_type(4) )) float float4;
7 typedef float t3 __attribute__ ((vector_size (16)));
8 typedef __typeof__(sizeof(int)) size_t;
9 typedef unsigned long ulong2 __attribute__ ((ext_vector_type(2)));
10 typedef size_t stride4 __attribute__((ext_vector_type(4)));
11 
12 static void test() {
13     float2 vec2;
14     float4 vec4, vec4_2;
15     int4 ivec4;
16     short8 ish8;
17     t3 vec4_3;
18     int *ptr;
19     int i;
20 
21     vec4 = 5.0f;
22     vec4 = (float4)5.0f;
23     vec4 = (float4)5;
24     vec4 = (float4)vec4_3;
25 
26     ivec4 = (int4)5.0f;
27     ivec4 = (int4)5;
28     ivec4 = (int4)vec4_3;
29 
30     i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}}
31     i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}}
32 
33     ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
34 
35     vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}}
36 
37     ish8 += 5; // expected-error {{can't convert between vector values of different size ('short8' and 'int')}}
38     ish8 += (short)5;
39     ivec4 *= 5;
40      vec4 /= 5.2f;
41      vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' and 'int')}}
42     ivec4 %= 4;
43     ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' and 'float4')}}
44     ivec4 += (int4)vec4;
45     ivec4 -= ivec4;
46     ivec4 |= ivec4;
47     ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}}
48 }
49 
50 typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}}
51 
52 void inc(float2 f2) {
53   f2++; // expected-error{{cannot increment value of type 'float2'}}
54   __real f2; // expected-error{{invalid type 'float2' to __real operator}}
55 }
56 
57 typedef enum
58 {
59     uchar_stride = 1,
60     uchar4_stride = 4,
61     ushort4_stride = 8,
62     short4_stride = 8,
63     uint4_stride = 16,
64     int4_stride = 16,
65     float4_stride = 16,
66 } PixelByteStride;
67 
68 stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride);
69 stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride)
70 {
71     stride4 stride;
72     // This previously caused an assertion failure.
73     stride.lo = ((ulong2) x) * pixelByteStride; // no-warning
74     return stride;
75 }
76 
77