diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-08-05 12:55:36 +0500 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 19:00:29 +0100 |
commit | c24d0e9033df80b564e7e72803195ad10c1e4221 (patch) | |
tree | 2be07644784956519d275ff650369359b6f1ab2c | |
parent | f26df74ce3c20a391bb1e23aded851f971bca585 (diff) | |
download | gcc-c24d0e9033df80b564e7e72803195ad10c1e4221.zip gcc-c24d0e9033df80b564e7e72803195ad10c1e4221.tar.gz gcc-c24d0e9033df80b564e7e72803195ad10c1e4221.tar.bz2 |
gccrs: [E0308] array misamatch types
gcc/rust/ChangeLog:
* backend/rust-compile.cc (HIRCompileBase::verify_array_capacities):
Added ErrorCode.
gcc/testsuite/ChangeLog:
* rust/compile/arrays2.rs: changed comment to pass
testcase.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 11 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/arrays2.rs | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 2c2a236..93f740f 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -401,11 +401,12 @@ HIRCompileBase::verify_array_capacities (tree ltype, tree rtype, if (ltype_length != rtype_length) { - rust_error_at ( - rvalue_locus, - "expected an array with a fixed size of " HOST_WIDE_INT_PRINT_UNSIGNED - " elements, found one with " HOST_WIDE_INT_PRINT_UNSIGNED " elements", - ltype_length, rtype_length); + rust_error_at (rvalue_locus, ErrorCode::E0308, + "mismatched types, expected an array with a fixed size " + "of " HOST_WIDE_INT_PRINT_UNSIGNED + " elements, found one with " HOST_WIDE_INT_PRINT_UNSIGNED + " elements", + ltype_length, rtype_length); return false; } diff --git a/gcc/testsuite/rust/compile/arrays2.rs b/gcc/testsuite/rust/compile/arrays2.rs index c96f4f7d..668bcf0 100644 --- a/gcc/testsuite/rust/compile/arrays2.rs +++ b/gcc/testsuite/rust/compile/arrays2.rs @@ -1,5 +1,5 @@ // { dg-additional-options "-w" } fn main() { let array: [i32; 5] = [1, 2, 3]; - // { dg-error "expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 } + // { dg-error "mismatched types, expected an array with a fixed size of 5 elements, found one with 3 elements" "" { target *-*-* } .-1 } } |