Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversions |
Anders Carlsson | a64db8f | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 2 | |
| 3 | typedef long long t1 __attribute__ ((vector_size (8))); |
| 4 | typedef char t2 __attribute__ ((vector_size (16))); |
| 5 | typedef float t3 __attribute__ ((vector_size (16))); |
| 6 | |
| 7 | void f() |
| 8 | { |
| 9 | t1 v1; |
| 10 | t2 v2; |
| 11 | t3 v3; |
| 12 | |
| 13 | v2 = (t2)v1; // -expected-error {{invalid conversion between vector type \ |
Anders Carlsson | a64db8f | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 14 | 't2' and 't1' of different size}} |
Nate Begeman | 58d29a4 | 2009-06-26 00:50:28 +0000 | [diff] [blame] | 15 | v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \ |
| 16 | 't1' and 't2' of different size}} |
Anders Carlsson | a64db8f | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 17 | v3 = (t3)v2; |
| 18 | |
| 19 | v1 = (t1)(char *)10; // -expected-error {{invalid conversion between vector \ |
| 20 | type 't1' and scalar type 'char *'}} |
| 21 | v1 = (t1)(long long)10; |
| 22 | v1 = (t1)(short)10; // -expected-error {{invalid conversion between vector \ |
Eli Friedman | 199ea95 | 2009-08-15 19:02:19 +0000 | [diff] [blame] | 23 | type 't1' and integer type 'short' of different size}} |
Anders Carlsson | a64db8f | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 24 | |
| 25 | long long r1 = (long long)v1; |
| 26 | short r2 = (short)v1; // -expected-error {{invalid conversion between vector \ |
| 27 | type 't1' and integer type 'short' of different size}} |
| 28 | char *r3 = (char *)v1; // -expected-error {{invalid conversion between vector\ |
| 29 | type 't1' and scalar type 'char *'}} |
| 30 | } |
Chris Lattner | 00cb00e | 2009-04-17 18:39:25 +0000 | [diff] [blame] | 31 | |
| 32 | |
Douglas Gregor | a41a8c5 | 2010-04-22 00:20:18 +0000 | [diff] [blame^] | 33 | void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}} |
Chris Lattner | 00cb00e | 2009-04-17 18:39:25 +0000 | [diff] [blame] | 34 | |
| 35 | void f3(t3 Y) { |
Douglas Gregor | d4eea83 | 2010-04-09 00:35:39 +0000 | [diff] [blame] | 36 | f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}} |
Chris Lattner | 00cb00e | 2009-04-17 18:39:25 +0000 | [diff] [blame] | 37 | } |
| 38 | |