]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/simd-intrinsic-generic-cast.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / simd-intrinsic-generic-cast.rs
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.
4 //
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.
10
11 #![feature(repr_simd, platform_intrinsics, rustc_attrs)]
12
13 #[repr(simd)]
14 #[derive(Copy, Clone)]
15 #[allow(non_camel_case_types)]
16 struct i32x4(i32, i32, i32, i32);
17 #[repr(simd)]
18 #[derive(Copy, Clone)]
19 #[allow(non_camel_case_types)]
20 struct i32x8(i32, i32, i32, i32,
21 i32, i32, i32, i32);
22
23 #[repr(simd)]
24 #[derive(Copy, Clone)]
25 #[allow(non_camel_case_types)]
26 struct f32x4(f32, f32, f32, f32);
27 #[repr(simd)]
28 #[derive(Copy, Clone)]
29 #[allow(non_camel_case_types)]
30 struct f32x8(f32, f32, f32, f32,
31 f32, f32, f32, f32);
32
33
34 extern "platform-intrinsic" {
35 fn simd_cast<T, U>(x: T) -> U;
36 }
37
38 #[rustc_no_mir] // FIXME #27840 MIR doesn't provide precise spans for calls.
39 fn main() {
40 let x = i32x4(0, 0, 0, 0);
41
42 unsafe {
43 simd_cast::<i32, i32>(0);
44 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
45 simd_cast::<i32, i32x4>(0);
46 //~^ ERROR expected SIMD input type, found non-SIMD `i32`
47 simd_cast::<i32x4, i32>(x);
48 //~^ ERROR expected SIMD return type, found non-SIMD `i32`
49 simd_cast::<_, i32x8>(x);
50 //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8
51 }
52 }