1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
2f4a2713aSLionel Sambuc typedef unsigned int v2u __attribute__ ((vector_size (8)));
3f4a2713aSLionel Sambuc typedef signed int v2s __attribute__ ((vector_size (8)));
4f4a2713aSLionel Sambuc typedef signed int v1s __attribute__ ((vector_size (4)));
5f4a2713aSLionel Sambuc typedef float v2f __attribute__ ((vector_size(8)));
6f4a2713aSLionel Sambuc typedef signed short v4ss __attribute__ ((vector_size (8)));
7f4a2713aSLionel Sambuc
test1()8f4a2713aSLionel Sambuc void test1() {
9f4a2713aSLionel Sambuc v2s v1;
10f4a2713aSLionel Sambuc v2u v2;
11f4a2713aSLionel Sambuc v1s v3;
12f4a2713aSLionel Sambuc v2f v4;
13f4a2713aSLionel Sambuc v4ss v5;
14f4a2713aSLionel Sambuc
15*0a6a1f1dSLionel Sambuc v1 = v2; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2u' (vector of 2 'unsigned int' values)}}
16*0a6a1f1dSLionel Sambuc v1 = v3; // expected-error {{assigning to 'v2s' (vector of 2 'int' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
17*0a6a1f1dSLionel Sambuc v1 = v4; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2f' (vector of 2 'float' values)}}
18*0a6a1f1dSLionel Sambuc v1 = v5; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v4ss' (vector of 4 'short' values)}}
19f4a2713aSLionel Sambuc
20*0a6a1f1dSLionel Sambuc v2 = v1; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v2s' (vector of 2 'int' values)}}
21*0a6a1f1dSLionel Sambuc v2 = v3; // expected-error {{assigning to 'v2u' (vector of 2 'unsigned int' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
22*0a6a1f1dSLionel Sambuc v2 = v4; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v2f' (vector of 2 'float' values)}}
23*0a6a1f1dSLionel Sambuc v2 = v5; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v4ss' (vector of 4 'short' values)}}
24f4a2713aSLionel Sambuc
25*0a6a1f1dSLionel Sambuc v3 = v1; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2s' (vector of 2 'int' values)}}
26*0a6a1f1dSLionel Sambuc v3 = v2; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2u' (vector of 2 'unsigned int' values)}}
27*0a6a1f1dSLionel Sambuc v3 = v4; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2f' (vector of 2 'float' values)}}
28*0a6a1f1dSLionel Sambuc v3 = v5; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v4ss'}}
29f4a2713aSLionel Sambuc
30*0a6a1f1dSLionel Sambuc v4 = v1; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v2s' (vector of 2 'int' values)}}
31*0a6a1f1dSLionel Sambuc v4 = v2; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v2u' (vector of 2 'unsigned int' values)}}
32*0a6a1f1dSLionel Sambuc v4 = v3; // expected-error {{assigning to 'v2f' (vector of 2 'float' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
33*0a6a1f1dSLionel Sambuc v4 = v5; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v4ss' (vector of 4 'short' values)}}
34f4a2713aSLionel Sambuc
35*0a6a1f1dSLionel Sambuc v5 = v1; // expected-warning {{incompatible vector types assigning to 'v4ss' (vector of 4 'short' values) from 'v2s' (vector of 2 'int' values)}}
36*0a6a1f1dSLionel Sambuc v5 = v2; // expected-warning {{incompatible vector types assigning to 'v4ss' (vector of 4 'short' values) from 'v2u' (vector of 2 'unsigned int' values)}}
37*0a6a1f1dSLionel Sambuc v5 = v3; // expected-error {{assigning to 'v4ss' (vector of 4 'short' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
38*0a6a1f1dSLionel Sambuc v5 = v4; // expected-warning {{incompatible vector types assigning to 'v4ss' (vector of 4 'short' values) from 'v2f'}}
39f4a2713aSLionel Sambuc }
40f4a2713aSLionel Sambuc
41f4a2713aSLionel Sambuc // PR2263
test2(float a,int b)42f4a2713aSLionel Sambuc float test2(__attribute__((vector_size(16))) float a, int b) {
43f4a2713aSLionel Sambuc return a[b];
44f4a2713aSLionel Sambuc }
45f4a2713aSLionel Sambuc
46f4a2713aSLionel Sambuc // PR4838
47f4a2713aSLionel Sambuc typedef long long __attribute__((__vector_size__(2 * sizeof(long long))))
48f4a2713aSLionel Sambuc longlongvec;
49f4a2713aSLionel Sambuc
50f4a2713aSLionel Sambuc void test3a(longlongvec *); // expected-note{{passing argument to parameter here}}
test3(const unsigned * src)51f4a2713aSLionel Sambuc void test3(const unsigned *src) {
52f4a2713aSLionel Sambuc test3a(src); // expected-warning {{incompatible pointer types passing 'const unsigned int *' to parameter of type 'longlongvec *'}}
53f4a2713aSLionel Sambuc }
54