From c1a34729e1a9e35af053c1c7ac76de6f2de3dfaf Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 30 Aug 2023 08:43:20 +0200 Subject: [PATCH] organize failing ABI compat tests and add some more --- .../abi_mismatch_int_vs_float.rs | 7 +++++++ .../abi_mismatch_int_vs_float.stderr | 15 +++++++++++++++ ...ast_fn_ptr4.rs => abi_mismatch_raw_pointer.rs} | 0 ...tr4.stderr => abi_mismatch_raw_pointer.stderr} | 4 ++-- ...ast_fn_ptr5.rs => abi_mismatch_return_type.rs} | 0 ...tr5.stderr => abi_mismatch_return_type.stderr} | 4 ++-- .../{cast_fn_ptr2.rs => abi_mismatch_simple.rs} | 0 ..._fn_ptr2.stderr => abi_mismatch_simple.stderr} | 4 ++-- ...st_fn_ptr3.rs => abi_mismatch_too_few_args.rs} | 0 ...r3.stderr => abi_mismatch_too_few_args.stderr} | 4 ++-- ...t_fn_ptr1.rs => abi_mismatch_too_many_args.rs} | 0 ...1.stderr => abi_mismatch_too_many_args.stderr} | 4 ++-- .../fail/function_pointers/abi_mismatch_vector.rs | 11 +++++++++++ .../function_pointers/abi_mismatch_vector.stderr | 15 +++++++++++++++ 14 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.rs create mode 100644 src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.stderr rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr4.rs => abi_mismatch_raw_pointer.rs} (100%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr4.stderr => abi_mismatch_raw_pointer.stderr} (85%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr5.rs => abi_mismatch_return_type.rs} (100%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr5.stderr => abi_mismatch_return_type.stderr} (84%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr2.rs => abi_mismatch_simple.rs} (100%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr2.stderr => abi_mismatch_simple.stderr} (85%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr3.rs => abi_mismatch_too_few_args.rs} (100%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr3.stderr => abi_mismatch_too_few_args.stderr} (83%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr1.rs => abi_mismatch_too_many_args.rs} (100%) rename src/tools/miri/tests/fail/function_pointers/{cast_fn_ptr1.stderr => abi_mismatch_too_many_args.stderr} (83%) create mode 100644 src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.rs create mode 100644 src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.stderr diff --git a/src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.rs new file mode 100644 index 00000000000..a1fda329e8d --- /dev/null +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.rs @@ -0,0 +1,7 @@ +fn main() { + fn f(_: f32) {} + + let g = unsafe { std::mem::transmute::(f) }; + + g(42) //~ ERROR: calling a function with argument of type f32 passing data of type i32 +} diff --git a/src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.stderr new file mode 100644 index 00000000000..a53126c733e --- /dev/null +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_int_vs_float.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with argument of type f32 passing data of type i32 + --> $DIR/abi_mismatch_int_vs_float.rs:LL:CC + | +LL | g(42) + | ^^^^^ calling a function with argument of type f32 passing data of type i32 + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/abi_mismatch_int_vs_float.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error + diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr4.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_raw_pointer.rs similarity index 100% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr4.rs rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_raw_pointer.rs diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr4.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_raw_pointer.stderr similarity index 85% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr4.stderr rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_raw_pointer.stderr index 610425658fe..6eacfeece14 100644 --- a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr4.stderr +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_raw_pointer.stderr @@ -1,5 +1,5 @@ error: Undefined Behavior: calling a function with argument of type *const [i32] passing data of type *const i32 - --> $DIR/cast_fn_ptr4.rs:LL:CC + --> $DIR/abi_mismatch_raw_pointer.rs:LL:CC | LL | g(&42 as *const i32) | ^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type *const [i32] passing data of type *const i32 @@ -7,7 +7,7 @@ LL | g(&42 as *const i32) = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: BACKTRACE: - = note: inside `main` at $DIR/cast_fn_ptr4.rs:LL:CC + = note: inside `main` at $DIR/abi_mismatch_raw_pointer.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr5.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_return_type.rs similarity index 100% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr5.rs rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_return_type.rs diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr5.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_return_type.stderr similarity index 84% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr5.stderr rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_return_type.stderr index c4e08b58430..eedc1235773 100644 --- a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr5.stderr +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_return_type.stderr @@ -1,5 +1,5 @@ error: Undefined Behavior: calling a function with return type u32 passing return place of type () - --> $DIR/cast_fn_ptr5.rs:LL:CC + --> $DIR/abi_mismatch_return_type.rs:LL:CC | LL | g() | ^^^ calling a function with return type u32 passing return place of type () @@ -7,7 +7,7 @@ LL | g() = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: BACKTRACE: - = note: inside `main` at $DIR/cast_fn_ptr5.rs:LL:CC + = note: inside `main` at $DIR/abi_mismatch_return_type.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr2.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_simple.rs similarity index 100% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr2.rs rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_simple.rs diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr2.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_simple.stderr similarity index 85% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr2.stderr rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_simple.stderr index 086712e0d13..bc500a90b77 100644 --- a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr2.stderr +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_simple.stderr @@ -1,5 +1,5 @@ error: Undefined Behavior: calling a function with argument of type (i32, i32) passing data of type i32 - --> $DIR/cast_fn_ptr2.rs:LL:CC + --> $DIR/abi_mismatch_simple.rs:LL:CC | LL | g(42) | ^^^^^ calling a function with argument of type (i32, i32) passing data of type i32 @@ -7,7 +7,7 @@ LL | g(42) = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: BACKTRACE: - = note: inside `main` at $DIR/cast_fn_ptr2.rs:LL:CC + = note: inside `main` at $DIR/abi_mismatch_simple.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr3.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_few_args.rs similarity index 100% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr3.rs rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_few_args.rs diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr3.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_few_args.stderr similarity index 83% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr3.stderr rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_few_args.stderr index 55fd7d60720..558d83bcfd2 100644 --- a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr3.stderr +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_few_args.stderr @@ -1,5 +1,5 @@ error: Undefined Behavior: calling a function with fewer arguments than it requires - --> $DIR/cast_fn_ptr3.rs:LL:CC + --> $DIR/abi_mismatch_too_few_args.rs:LL:CC | LL | g() | ^^^ calling a function with fewer arguments than it requires @@ -7,7 +7,7 @@ LL | g() = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: BACKTRACE: - = note: inside `main` at $DIR/cast_fn_ptr3.rs:LL:CC + = note: inside `main` at $DIR/abi_mismatch_too_few_args.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr1.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_many_args.rs similarity index 100% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr1.rs rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_many_args.rs diff --git a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr1.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_many_args.stderr similarity index 83% rename from src/tools/miri/tests/fail/function_pointers/cast_fn_ptr1.stderr rename to src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_many_args.stderr index bb2a2637959..dc12073952f 100644 --- a/src/tools/miri/tests/fail/function_pointers/cast_fn_ptr1.stderr +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_too_many_args.stderr @@ -1,5 +1,5 @@ error: Undefined Behavior: calling a function with more arguments than it expected - --> $DIR/cast_fn_ptr1.rs:LL:CC + --> $DIR/abi_mismatch_too_many_args.rs:LL:CC | LL | g(42) | ^^^^^ calling a function with more arguments than it expected @@ -7,7 +7,7 @@ LL | g(42) = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information = note: BACKTRACE: - = note: inside `main` at $DIR/cast_fn_ptr1.rs:LL:CC + = note: inside `main` at $DIR/abi_mismatch_too_many_args.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.rs new file mode 100644 index 00000000000..80f357b61ba --- /dev/null +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.rs @@ -0,0 +1,11 @@ +#![feature(portable_simd)] +use std::simd; + +fn main() { + fn f(_: simd::u32x8) {} + + // These two vector types have the same size but are still not compatible. + let g = unsafe { std::mem::transmute::(f) }; + + g(Default::default()) //~ ERROR: calling a function with argument of type std::simd::Simd passing data of type std::simd::Simd +} diff --git a/src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.stderr b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.stderr new file mode 100644 index 00000000000..7dcca1e85b8 --- /dev/null +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_vector.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: calling a function with argument of type std::simd::Simd passing data of type std::simd::Simd + --> $DIR/abi_mismatch_vector.rs:LL:CC + | +LL | g(Default::default()) + | ^^^^^^^^^^^^^^^^^^^^^ calling a function with argument of type std::simd::Simd passing data of type std::simd::Simd + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + = note: BACKTRACE: + = note: inside `main` at $DIR/abi_mismatch_vector.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to previous error +