diff options
| author | bors <bors@rust-lang.org> | 2015-08-31 03:00:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-08-31 03:00:21 +0000 |
| commit | 811868ec6fcde0a2e43025542e8fd87e74f64d0b (patch) | |
| tree | b527a713a1da88508b4d5099ce129bc229f5276b | |
| parent | 8f28c9b01ee5ff7e73bb81b3364f26b6ad4060a2 (diff) | |
| parent | bc024d261ee61276101985807d9ce6fff38d856c (diff) | |
| download | rust-811868ec6fcde0a2e43025542e8fd87e74f64d0b.tar.gz rust-811868ec6fcde0a2e43025542e8fd87e74f64d0b.zip | |
Auto merge of #28103 - GuillaumeGomez:fix-intrinsic, r=huonw
Fixes #28062
| -rw-r--r-- | src/librustc_typeck/check/intrinsic.rs | 7 | ||||
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 29 | ||||
| -rw-r--r-- | src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs | 24 |
3 files changed, 59 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 83ac406119e..e75e512594c 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -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, diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 9f811eda441..a7c1fbb2719 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -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! +} +``` +"##, } diff --git a/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs b/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs new file mode 100644 index 00000000000..a224690af76 --- /dev/null +++ b/src/test/compile-fail/intrinsic-invalid-number-of-arguments.rs @@ -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() { +} |
