Auto merge of #28103 - GuillaumeGomez:fix-intrinsic, r=huonw

Fixes #28062
This commit is contained in:
bors 2015-08-31 03:00:21 +00:00
commit 811868ec6f
3 changed files with 59 additions and 1 deletions

View File

@ -408,6 +408,13 @@ pub fn check_platform_intrinsic_type(ccx: &CrateCtxt,
let mut structural_to_nomimal = HashMap::new();
let sig = tcx.no_late_bound_regions(i_ty.ty.fn_sig()).unwrap();
if intr.inputs.len() != sig.inputs.len() {
span_err!(tcx.sess, it.span, E0444,
"platform-specific intrinsic has invalid number of \
arguments: found {}, expected {}",
intr.inputs.len(), sig.inputs.len());
return
}
let input_pairs = intr.inputs.iter().zip(&sig.inputs);
for (i, (expected_arg, arg)) in input_pairs.enumerate() {
match_intrinsic_type_to_type(tcx, &format!("argument {}", i + 1), it.span,

View File

@ -3018,7 +3018,34 @@ PhantomData can also be used to express information about unused type
parameters. You can read more about it in the API documentation:
https://doc.rust-lang.org/std/marker/struct.PhantomData.html
"##
"##,
E0444: r##"
A platform-specific intrinsic function has wrong number of arguments.
Erroneous code example:
```
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32;
// error: platform-specific intrinsic has invalid number of arguments
}
```
Please refer to the function declaration to see if it corresponds
with yours. Example:
```
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok!
}
```
"##,
}

View File

@ -0,0 +1,24 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test number of arguments in platform-specific intrinsic function
// This is the error E0444
#![feature(repr_simd, platform_intrinsics)]
#[repr(simd)]
struct f64x2(f64, f64);
extern "platform-intrinsic" {
fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ platform-specific intrinsic
}
pub fn main() {
}