File: vector-cast.c

package info (click to toggle)
llvm-toolchain-3.4 1%3A3.4.2-13
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 253,236 kB
  • ctags: 276,203
  • sloc: cpp: 1,665,580; ansic: 298,647; asm: 206,157; objc: 84,350; python: 73,119; sh: 23,466; perl: 5,679; makefile: 5,542; ml: 5,250; pascal: 2,467; lisp: 1,420; xml: 679; cs: 236; csh: 117
file content (38 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion

typedef long long t1 __attribute__ ((vector_size (8)));
typedef char t2 __attribute__ ((vector_size (16)));
typedef float t3 __attribute__ ((vector_size (16)));

void f()
{  
  t1 v1;
  t2 v2;
  t3 v3;
  
  v2 = (t2)v1; // expected-error {{invalid conversion between vector type \
't2' and 't1' of different size}}
  v1 = (t1)v2; // expected-error {{invalid conversion between vector type \
't1' and 't2' of different size}}
  v3 = (t3)v2;
  
  v1 = (t1)(char *)10; // expected-error {{invalid conversion between vector \
type 't1' and scalar type 'char *'}}
  v1 = (t1)(long long)10;
  v1 = (t1)(short)10; // expected-error {{invalid conversion between vector \
type 't1' and integer type 'short' of different size}}
  
  long long r1 = (long long)v1;
  short r2 = (short)v1; // expected-error {{invalid conversion between vector \
type 't1' and integer type 'short' of different size}}
  char *r3 = (char *)v1; // expected-error {{invalid conversion between vector\
 type 't1' and scalar type 'char *'}}
}


void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}

void f3(t3 Y) {
  f2(Y);  // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
}