Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversions |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 2 | typedef unsigned int v2u __attribute__ ((vector_size (8))); |
| 3 | typedef signed int v2s __attribute__ ((vector_size (8))); |
| 4 | typedef signed int v1s __attribute__ ((vector_size (4))); |
| 5 | typedef float v2f __attribute__ ((vector_size(8))); |
| 6 | typedef signed short v4ss __attribute__ ((vector_size (8))); |
| 7 | |
Chris Lattner | 6a2b926 | 2009-10-17 20:33:28 +0000 | [diff] [blame] | 8 | void test1() { |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 9 | v2s v1; |
| 10 | v2u v2; |
| 11 | v1s v3; |
| 12 | v2f v4; |
| 13 | v4ss v5; |
| 14 | |
Douglas Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame] | 15 | v1 = v2; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v2u'}} |
| 16 | v1 = v3; // expected-error {{assigning to 'v2s' from incompatible type 'v1s'}} |
| 17 | v1 = v4; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v2f'}} |
| 18 | v1 = v5; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v4ss'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 19 | |
Douglas Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame] | 20 | v2 = v1; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v2s'}} |
| 21 | v2 = v3; // expected-error {{assigning to 'v2u' from incompatible type 'v1s'}} |
| 22 | v2 = v4; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v2f'}} |
| 23 | v2 = v5; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v4ss'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 24 | |
Douglas Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame] | 25 | v3 = v1; // expected-error {{assigning to 'v1s' from incompatible type 'v2s'}} |
| 26 | v3 = v2; // expected-error {{assigning to 'v1s' from incompatible type 'v2u'}} |
| 27 | v3 = v4; // expected-error {{assigning to 'v1s' from incompatible type 'v2f'}} |
| 28 | v3 = v5; // expected-error {{assigning to 'v1s' from incompatible type 'v4ss'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 29 | |
Douglas Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame] | 30 | v4 = v1; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v2s'}} |
| 31 | v4 = v2; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v2u'}} |
| 32 | v4 = v3; // expected-error {{assigning to 'v2f' from incompatible type 'v1s'}} |
| 33 | v4 = v5; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v4ss'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 34 | |
Douglas Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame] | 35 | v5 = v1; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2s'}} |
| 36 | v5 = v2; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2u'}} |
| 37 | v5 = v3; // expected-error {{assigning to 'v4ss' from incompatible type 'v1s'}} |
| 38 | v5 = v4; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2f'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 39 | } |
Chris Lattner | a989def | 2008-05-12 18:31:17 +0000 | [diff] [blame] | 40 | |
| 41 | // PR2263 |
Chris Lattner | 6a2b926 | 2009-10-17 20:33:28 +0000 | [diff] [blame] | 42 | float test2(__attribute__((vector_size(16))) float a, int b) { |
Chris Lattner | a989def | 2008-05-12 18:31:17 +0000 | [diff] [blame] | 43 | return a[b]; |
| 44 | } |
| 45 | |
Chris Lattner | 6a2b926 | 2009-10-17 20:33:28 +0000 | [diff] [blame] | 46 | // PR4838 |
| 47 | typedef long long __attribute__((__vector_size__(2 * sizeof(long long)))) |
| 48 | longlongvec; |
| 49 | |
Douglas Gregor | a41a8c5 | 2010-04-22 00:20:18 +0000 | [diff] [blame] | 50 | void test3a(longlongvec *); // expected-note{{passing argument to parameter here}} |
Chris Lattner | 6a2b926 | 2009-10-17 20:33:28 +0000 | [diff] [blame] | 51 | void test3(const unsigned *src) { |
Chris Lattner | 58f9e13 | 2010-09-05 00:04:01 +0000 | [diff] [blame] | 52 | test3a(src); // expected-warning {{incompatible pointer types passing 'const unsigned int *' to parameter of type 'longlongvec *'}} |
Chris Lattner | 6a2b926 | 2009-10-17 20:33:28 +0000 | [diff] [blame] | 53 | } |