]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/simd-intrinsic-generic-elements.rs
Auto merge of #27586 - GuillaumeGomez:patch-2, r=Manishearth
[rust.git] / src / test / compile-fail / simd-intrinsic-generic-elements.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)]
12
13 #[repr(simd)]
14 #[derive(Copy, Clone)]
15 #[allow(non_camel_case_types)]
16 struct i32x2(i32, i32);
17 #[repr(simd)]
18 #[derive(Copy, Clone)]
19 #[allow(non_camel_case_types)]
20 struct i32x3(i32, i32, i32);
21 #[repr(simd)]
22 #[derive(Copy, Clone)]
23 #[allow(non_camel_case_types)]
24 struct i32x4(i32, i32, i32, i32);
25 #[repr(simd)]
26 #[derive(Copy, Clone)]
27 #[allow(non_camel_case_types)]
28 struct i32x8(i32, i32, i32, i32,
29              i32, i32, i32, i32);
30
31 #[repr(simd)]
32 #[derive(Copy, Clone)]
33 #[allow(non_camel_case_types)]
34 struct f32x2(f32, f32);
35 #[repr(simd)]
36 #[derive(Copy, Clone)]
37 #[allow(non_camel_case_types)]
38 struct f32x3(f32, f32, f32);
39 #[repr(simd)]
40 #[derive(Copy, Clone)]
41 #[allow(non_camel_case_types)]
42 struct f32x4(f32, f32, f32, f32);
43 #[repr(simd)]
44 #[derive(Copy, Clone)]
45 #[allow(non_camel_case_types)]
46 struct f32x8(f32, f32, f32, f32,
47              f32, f32, f32, f32);
48
49 extern "platform-intrinsic" {
50     fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
51     fn simd_extract<T, E>(x: T, idx: u32) -> E;
52
53     fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
54     fn simd_shuffle3<T, U>(x: T, y: T, idx: [u32; 3]) -> U;
55     fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U;
56     fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
57 }
58
59 fn main() {
60     let x = i32x4(0, 0, 0, 0);
61
62     unsafe {
63         simd_insert(0, 0, 0);
64         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
65         simd_insert(x, 0, 1.0);
66         //~^ ERROR expected inserted type `i32` (element of input `i32x4`), found `f64`
67         simd_extract::<_, f32>(x, 0);
68         //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32`
69
70         simd_shuffle2::<i32, i32>(0, 0, [0; 2]);
71         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
72         simd_shuffle3::<i32, i32>(0, 0, [0; 3]);
73         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
74         simd_shuffle4::<i32, i32>(0, 0, [0; 4]);
75         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
76         simd_shuffle8::<i32, i32>(0, 0, [0; 8]);
77         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
78
79         simd_shuffle2::<_, f32x2>(x, x, [0; 2]);
80 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
81         simd_shuffle3::<_, f32x3>(x, x, [0; 3]);
82 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32`
83         simd_shuffle4::<_, f32x4>(x, x, [0; 4]);
84 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
85         simd_shuffle8::<_, f32x8>(x, x, [0; 8]);
86 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
87
88         simd_shuffle2::<_, i32x8>(x, x, [0; 2]);
89         //~^ ERROR expected return type of length 2, found `i32x8` with length 8
90         simd_shuffle3::<_, i32x4>(x, x, [0; 3]);
91         //~^ ERROR expected return type of length 3, found `i32x4` with length 4
92         simd_shuffle4::<_, i32x3>(x, x, [0; 4]);
93         //~^ ERROR expected return type of length 4, found `i32x3` with length 3
94         simd_shuffle8::<_, i32x2>(x, x, [0; 8]);
95         //~^ ERROR expected return type of length 8, found `i32x2` with length 2
96     }
97 }