Chris Lattner | 00cb00e | 2009-04-17 18:39:25 +0000 | [diff] [blame^] | 1 | // RUN: clang-cc %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 | |
| 8 | void f() { |
| 9 | v2s v1; |
| 10 | v2u v2; |
| 11 | v1s v3; |
| 12 | v2f v4; |
| 13 | v4ss v5; |
| 14 | |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 15 | v1 = v2; // expected-warning {{incompatible vector types assigning 'v2u', expected 'v2s'}} |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 16 | v1 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2s'}} |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 17 | v1 = v4; // expected-warning {{incompatible vector types assigning 'v2f', expected 'v2s'}} |
| 18 | v1 = v5; // expected-warning {{incompatible vector types assigning 'v4ss', expected 'v2s'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 19 | |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 20 | v2 = v1; // expected-warning {{incompatible vector types assigning 'v2s', expected 'v2u'}} |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 21 | v2 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2u'}} |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 22 | v2 = v4; // expected-warning {{incompatible vector types assigning 'v2f', expected 'v2u'}} |
| 23 | v2 = v5; // expected-warning {{incompatible vector types assigning 'v4ss', expected 'v2u'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 24 | |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 25 | v3 = v1; // expected-error {{incompatible type assigning 'v2s', expected 'v1s'}} |
| 26 | v3 = v2; // expected-error {{incompatible type assigning 'v2u', expected 'v1s'}} |
| 27 | v3 = v4; // expected-error {{incompatible type assigning 'v2f', expected 'v1s'}} |
| 28 | v3 = v5; // expected-error {{incompatible type assigning 'v4ss', expected 'v1s'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 29 | |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 30 | v4 = v1; // expected-warning {{incompatible vector types assigning 'v2s', expected 'v2f'}} |
| 31 | v4 = v2; // expected-warning {{incompatible vector types assigning 'v2u', expected 'v2f'}} |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 32 | v4 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v2f'}} |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 33 | v4 = v5; // expected-warning {{incompatible vector types assigning 'v4ss', expected 'v2f'}} |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 34 | |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 35 | v5 = v1; // expected-warning {{incompatible vector types assigning 'v2s', expected 'v4ss'}} |
| 36 | v5 = v2; // expected-warning {{incompatible vector types assigning 'v2u', expected 'v4ss'}} |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 37 | v5 = v3; // expected-error {{incompatible type assigning 'v1s', expected 'v4ss'}} |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 38 | v5 = v4; // expected-warning {{incompatible vector types assigning 'v2f', expected 'v4ss'}} |
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 |
| 42 | float f2(__attribute__((vector_size(16))) float a, int b) { |
| 43 | return a[b]; |
| 44 | } |
| 45 | |