aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Sema/vector-bool-assign.c
blob: 8f9d7b17a1ecb600c22ba01df2ce09fb223f57a7 (plain)
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
// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s

typedef _Bool bool;

typedef __attribute__((ext_vector_type(8))) int v8i;
typedef __attribute__((ext_vector_type(8))) bool v8b;
typedef __attribute__((ext_vector_type(4))) float v4f;
typedef __attribute__((ext_vector_type(4))) bool v4b;

void foo(v8b);

v8b integral(v8i v) {
  v8b m1 = __builtin_convertvector(v, __attribute__((ext_vector_type(8))) int);
  v8b m2 = __builtin_convertvector(v, __attribute__((ext_vector_type(8))) unsigned);
  v8b m3 = __builtin_convertvector(v, __attribute__((ext_vector_type(8))) long);
  v8b m4 = __builtin_convertvector(v, __attribute__((ext_vector_type(8))) unsigned long);
  v8b m5 = __builtin_convertvector(v, __attribute__((ext_vector_type(8))) char);
  v8b m6 = __builtin_convertvector(v, __attribute__((ext_vector_type(8))) unsigned char);
  foo(v);
  return v;
}

v4b non_integral(v4f vf) {
  return vf; // expected-error{{returning 'v4f' (vector of 4 'float' values) from a function with incompatible result type 'v4b' (vector of 4 'bool' values}}
}

v4b size_mismatch(v8i v) {
  return v; // expected-error{{returning 'v8i' (vector of 8 'int' values) from a function with incompatible result type 'v4b' (vector of 4 'bool' values)}}
}