blob: 7fa6e86aa10e7dce0fa2aa7e71a958df8617e11a [file] [log] [blame]
David Blaikie1d23c422012-03-15 05:09:31 +00001// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion
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
Andy Gibbs4a529d22012-10-19 12:36:49 +000013 v2 = (t2)v1; // expected-error {{invalid conversion between vector type \
Anders Carlssona64db8f2007-11-27 05:51:55 +000014't2' and 't1' of different size}}
Andy Gibbs4a529d22012-10-19 12:36:49 +000015 v1 = (t1)v2; // expected-error {{invalid conversion between vector type \
Nate Begeman58d29a42009-06-26 00:50:28 +000016't1' and 't2' of different size}}
Anders Carlssona64db8f2007-11-27 05:51:55 +000017 v3 = (t3)v2;
18
Andy Gibbs4a529d22012-10-19 12:36:49 +000019 v1 = (t1)(char *)10; // expected-error {{invalid conversion between vector \
Anders Carlssona64db8f2007-11-27 05:51:55 +000020type 't1' and scalar type 'char *'}}
21 v1 = (t1)(long long)10;
Andy Gibbs4a529d22012-10-19 12:36:49 +000022 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;
Andy Gibbs4a529d22012-10-19 12:36:49 +000026 short r2 = (short)v1; // expected-error {{invalid conversion between vector \
Anders Carlssona64db8f2007-11-27 05:51:55 +000027type 't1' and integer type 'short' of different size}}
Andy Gibbs4a529d22012-10-19 12:36:49 +000028 char *r3 = (char *)v1; // expected-error {{invalid conversion between vector\
Anders Carlssona64db8f2007-11-27 05:51:55 +000029 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