1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that the simd_select intrinsic produces ok-ish error
12 // messages when misused.
14 #![feature(repr_simd, platform_intrinsics)]
15 #![allow(non_camel_case_types)]
18 #[derive(Copy, Clone)]
19 pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
22 #[derive(Copy, Clone)]
23 pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
26 #[derive(Copy, Clone, PartialEq)]
27 struct b8x4(pub i8, pub i8, pub i8, pub i8);
30 #[derive(Copy, Clone, PartialEq)]
31 struct b8x8(pub i8, pub i8, pub i8, pub i8,
32 pub i8, pub i8, pub i8, pub i8);
34 extern "platform-intrinsic" {
35 fn simd_select<T, U>(x: T, a: U, b: U) -> U;
36 fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
40 let m4 = b8x4(0, 0, 0, 0);
41 let m8 = b8x8(0, 0, 0, 0, 0, 0, 0, 0);
42 let x = u32x4(0, 0, 0, 0);
43 let z = f32x4(0.0, 0.0, 0.0, 0.0);
46 simd_select(m4, x, x);
48 simd_select(m8, x, x);
49 //~^ ERROR mismatched lengths: mask length `8` != other vector length `4`
52 //~^ ERROR mask element type is `u32`, expected `i_`
55 //~^ ERROR mask element type is `f32`, expected `i_`
57 simd_select_bitmask(0u8, x, x);
58 //~^ ERROR mask length `8` != other vector length `4`
60 simd_select_bitmask(0.0f32, x, x);
61 //~^ ERROR `f32` is not an integral type
63 simd_select_bitmask("x", x, x);
64 //~^ ERROR `&str` is not an integral type