diff --git a/gcc/rust/backend/rust-intrinsic-handlers.cc b/gcc/rust/backend/rust-intrinsic-handlers.cc index eb86c8ad9594..c676a076e10b 100644 --- a/gcc/rust/backend/rust-intrinsic-handlers.cc +++ b/gcc/rust/backend/rust-intrinsic-handlers.cc @@ -80,7 +80,7 @@ check_for_basic_integer_type (const std::string &intrinsic_str, { rust_error_at ( locus, - "%s intrinsics can only be used with basic integer types (got %qs)", + "%s intrinsic can only be used with basic integer types (got %qs)", intrinsic_str.c_str (), type->get_name ().c_str ()); } @@ -218,7 +218,7 @@ build_atomic_builtin_name (const std::string &prefix, location_t locus, auto type_size_str = allowed_types.find (type_name); - if (!check_for_basic_integer_type ("atomic", locus, operand_type)) + if (!check_for_basic_integer_type ("atomic operation", locus, operand_type)) return ""; result += type_size_str->second; @@ -255,7 +255,8 @@ unchecked_op (Context *ctx, TyTy::FnType *fntype, tree_code op) auto *monomorphized_type = fntype->get_substs ().at (0).get_param_ty ()->resolve (); - check_for_basic_integer_type ("unchecked operation", fntype->get_locus (), + auto call_locus = ctx->get_mappings ().lookup_location (fntype->get_ref ()); + check_for_basic_integer_type ("unchecked operation", call_locus, monomorphized_type); auto expr = build2 (op, TREE_TYPE (x), x, y); @@ -660,9 +661,9 @@ atomic_store (Context *ctx, TyTy::FnType *fntype, int ordering) auto monomorphized_type = fntype->get_substs ()[0].get_param_ty ()->resolve (); - auto builtin_name - = build_atomic_builtin_name ("atomic_store_", fntype->get_locus (), - monomorphized_type); + auto call_locus = ctx->get_mappings ().lookup_location (fntype->get_ref ()); + auto builtin_name = build_atomic_builtin_name ("atomic_store_", call_locus, + monomorphized_type); if (builtin_name.empty ()) return error_mark_node; @@ -777,8 +778,8 @@ ctlz_handler (Context *ctx, TyTy::FnType *fntype, bool nonzero) rust_assert (fntype->get_num_substitutions () == 1); auto *monomorphized_type = fntype->get_substs ().at (0).get_param_ty ()->resolve (); - if (!check_for_basic_integer_type ("ctlz", fntype->get_locus (), - monomorphized_type)) + auto call_locus = ctx->get_mappings ().lookup_location (fntype->get_ref ()); + if (!check_for_basic_integer_type ("ctlz", call_locus, monomorphized_type)) return error_mark_node; enter_intrinsic_block (ctx, fndecl); @@ -1542,8 +1543,8 @@ bswap_handler (Context *ctx, TyTy::FnType *fntype) auto *monomorphized_type = fntype->get_substs ().at (0).get_param_ty ()->resolve (); - check_for_basic_integer_type ("bswap", fntype->get_locus (), - monomorphized_type); + auto call_locus = ctx->get_mappings ().lookup_location (fntype->get_ref ()); + check_for_basic_integer_type ("bswap", call_locus, monomorphized_type); tree template_parameter_type = TyTyResolveCompile::compile (ctx, monomorphized_type); diff --git a/gcc/testsuite/rust/compile/bswap.rs b/gcc/testsuite/rust/compile/bswap.rs index a41607efc16b..2e1c920e2e52 100644 --- a/gcc/testsuite/rust/compile/bswap.rs +++ b/gcc/testsuite/rust/compile/bswap.rs @@ -9,9 +9,9 @@ pub trait Sized {} pub trait Copy {} extern "rust-intrinsic" { - pub fn bswap(x: T) -> T; // { dg-error "bswap intrinsics can only be used with basic integer types .got 'bool'." } + pub fn bswap(x: T) -> T; } fn main() { - let _ = bswap(true); + let _ = bswap(true); // { dg-error "bswap intrinsic can only be used with basic integer types .got .bool.." } } diff --git a/gcc/testsuite/rust/compile/ctlz.rs b/gcc/testsuite/rust/compile/ctlz.rs index b886be774ea8..625b8847bbf8 100644 --- a/gcc/testsuite/rust/compile/ctlz.rs +++ b/gcc/testsuite/rust/compile/ctlz.rs @@ -9,9 +9,9 @@ pub trait Sized {} pub trait Copy {} extern "rust-intrinsic" { - pub fn ctlz(x: T) -> u32; // { dg-error "ctlz intrinsics can only be used with basic integer types .got 'bool'." } + pub fn ctlz(x: T) -> u32; } fn main() { - let _ = ctlz(true); + let _ = ctlz(true); // { dg-error "ctlz intrinsic can only be used with basic integer types .got .bool.." } } diff --git a/gcc/testsuite/rust/compile/ctlz_nonzero.rs b/gcc/testsuite/rust/compile/ctlz_nonzero.rs index bf12728d2152..74c3fb96a8d5 100644 --- a/gcc/testsuite/rust/compile/ctlz_nonzero.rs +++ b/gcc/testsuite/rust/compile/ctlz_nonzero.rs @@ -9,11 +9,11 @@ pub trait Sized {} pub trait Copy {} extern "rust-intrinsic" { - pub fn ctlz_nonzero(x: T) -> u32; // { dg-error "ctlz intrinsics can only be used with basic integer types .got 'bool'." } + pub fn ctlz_nonzero(x: T) -> u32; } fn main() { unsafe { - let _ = ctlz_nonzero(true); + let _ = ctlz_nonzero(true); // { dg-error "ctlz intrinsic can only be used with basic integer types .got .bool.." } } } diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-5.rs b/gcc/testsuite/rust/compile/torture/intrinsics-5.rs index 28c4f191b181..39d717664332 100644 --- a/gcc/testsuite/rust/compile/torture/intrinsics-5.rs +++ b/gcc/testsuite/rust/compile/torture/intrinsics-5.rs @@ -65,8 +65,6 @@ mod copy_impls { extern "rust-intrinsic" { pub fn atomic_store_seqcst(dst: *mut T, value: T); - // { dg-error "atomic intrinsics can only be used with basic integer types .got .VeryLargeType.." "" { target *-*-* } .-1 } - // { dg-error "atomic intrinsics can only be used with basic integer types .got .bool.." "" { target *-*-* } .-2 } } struct VeryLargeType { @@ -100,6 +98,8 @@ fn main() { unsafe { atomic_store_seqcst(&mut dst, VeryLargeType::new(1)); + // { dg-error "atomic operation intrinsic can only be used with basic integer types .got .VeryLargeType.." "" { target *-*-* } .-1 } atomic_store_seqcst(&mut b, true); + // { dg-error "atomic operation intrinsic can only be used with basic integer types .got .bool.." "" { target *-*-* } .-1 } } } diff --git a/gcc/testsuite/rust/compile/torture/intrinsics-7.rs b/gcc/testsuite/rust/compile/torture/intrinsics-7.rs index 371066c1e6c2..159ebeab4325 100644 --- a/gcc/testsuite/rust/compile/torture/intrinsics-7.rs +++ b/gcc/testsuite/rust/compile/torture/intrinsics-7.rs @@ -9,11 +9,11 @@ pub trait Sized {} extern "rust-intrinsic" { pub fn unchecked_add(x: T, y: T) -> T; - // { dg-error "unchecked operation intrinsics can only be used with basic integer types .got .NotAdd.." "" { target *-*-* } .-1 } } fn main() { struct NotAdd; unsafe { unchecked_add(NotAdd, NotAdd) }; + // { dg-error "unchecked operation intrinsic can only be used with basic integer types .got .NotAdd.." "" { target *-*-* } .-1 } }