blob: a717e8611019140d923a6bc9028cec9391a3b685 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversions
Anders Carlssona64db8f2007-11-27 05:51:55 +00002
3typedef long long t1 __attribute__ ((vector_size (8)));
4typedef char t2 __attribute__ ((vector_size (16)));
5typedef float t3 __attribute__ ((vector_size (16)));
6
7void f()
8{
9 t1 v1;
10 t2 v2;
11 t3 v3;
12
13 v2 = (t2)v1; // -expected-error {{invalid conversion between vector type \
Anders Carlssona64db8f2007-11-27 05:51:55 +000014't2' and 't1' of different size}}
Nate Begeman58d29a42009-06-26 00:50:28 +000015 v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \
16't1' and 't2' of different size}}
Anders Carlssona64db8f2007-11-27 05:51:55 +000017 v3 = (t3)v2;
18
19 v1 = (t1)(char *)10; // -expected-error {{invalid conversion between vector \
20type 't1' and scalar type 'char *'}}
21 v1 = (t1)(long long)10;
22 v1 = (t1)(short)10; // -expected-error {{invalid conversion between vector \
Eli Friedman199ea952009-08-15 19:02:19 +000023type 't1' and integer type 'short' of different size}}
Anders Carlssona64db8f2007-11-27 05:51:55 +000024
25 long long r1 = (long long)v1;
26 short r2 = (short)v1; // -expected-error {{invalid conversion between vector \
27type '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 Lattner00cb00e2009-04-17 18:39:25 +000031
32
Douglas Gregora41a8c52010-04-22 00:20:18 +000033void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
Chris Lattner00cb00e2009-04-17 18:39:25 +000034
35void f3(t3 Y) {
Douglas Gregord4eea832010-04-09 00:35:39 +000036 f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
Chris Lattner00cb00e2009-04-17 18:39:25 +000037}
38