diff options
Diffstat (limited to 'tests/ui/codegen')
9 files changed, 114 insertions, 1 deletions
diff --git a/tests/ui/codegen/equal-pointers-unequal/as-cast/segfault.rs b/tests/ui/codegen/equal-pointers-unequal/as-cast/segfault.rs index 70cbb9a52f7..c69565a81f2 100644 --- a/tests/ui/codegen/equal-pointers-unequal/as-cast/segfault.rs +++ b/tests/ui/codegen/equal-pointers-unequal/as-cast/segfault.rs @@ -55,6 +55,7 @@ fn main() { // The `Box` has been deallocated by now, so this is a dangling reference! let r: &u8 = &*r; println!("{:p}", r); + println!("{}", i); // The following might segfault. Or it might not. // Depends on the platform semantics diff --git a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs index ad1d7b56c8c..b74f85290a7 100644 --- a/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs +++ b/tests/ui/codegen/equal-pointers-unequal/exposed-provenance/segfault.rs @@ -58,6 +58,7 @@ fn main() { // The `Box` has been deallocated by now, so this is a dangling reference! let r: &u8 = &*r; println!("{:p}", r); + println!("{}", i); // The following might segfault. Or it might not. // Depends on the platform semantics diff --git a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs index 637f0042ada..18d5bd33355 100644 --- a/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs +++ b/tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs @@ -58,6 +58,7 @@ fn main() { // The `Box` has been deallocated by now, so this is a dangling reference! let r: &u8 = &*r; println!("{:p}", r); + println!("{}", i); // The following might segfault. Or it might not. // Depends on the platform semantics diff --git a/tests/ui/codegen/i128-shift-overflow-check-76042.rs b/tests/ui/codegen/i128-shift-overflow-check-76042.rs new file mode 100644 index 00000000000..7ae0806216c --- /dev/null +++ b/tests/ui/codegen/i128-shift-overflow-check-76042.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/76042 +//@ run-pass +//@ compile-flags: -Coverflow-checks=off -Ccodegen-units=1 -Copt-level=0 + +fn foo(a: i128, b: i128, s: u32) -> (i128, i128) { + if s == 128 { + (0, 0) + } else { + (b >> s, a >> s) + } +} +fn main() { + let r = foo(0, 8, 1); + if r.0 != 4 { + panic!(); + } +} diff --git a/tests/ui/codegen/indirect-nocapture.rs b/tests/ui/codegen/indirect-nocapture.rs new file mode 100644 index 00000000000..78024a94c0d --- /dev/null +++ b/tests/ui/codegen/indirect-nocapture.rs @@ -0,0 +1,15 @@ +// Regression test for issue #137668 where an indirect argument have been marked as nocapture +// despite the fact that callee did in fact capture the address. +// +//@ run-pass +//@ compile-flags: -Copt-level=2 + +#[inline(never)] +pub fn f(a: [u32; 64], b: [u32; 64]) -> bool { + &a as *const _ as usize != &b as *const _ as usize +} + +fn main() { + static S: [u32; 64] = [0; 64]; + assert!(f(S, S)); +} diff --git a/tests/ui/codegen/matrix-row-swap-54462.rs b/tests/ui/codegen/matrix-row-swap-54462.rs new file mode 100644 index 00000000000..6bfc600399a --- /dev/null +++ b/tests/ui/codegen/matrix-row-swap-54462.rs @@ -0,0 +1,26 @@ +// https://github.com/rust-lang/rust/issues/54462 +//@ run-pass +// +//@ compile-flags: -Ccodegen-units=1 -O + +fn linidx(row: usize, col: usize) -> usize { + row * 1 + col * 3 +} + +fn main() { + let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0]; + + for i in 0..2 { + for j in i+1..3 { + if mat[linidx(j, 3)] > mat[linidx(i, 3)] { + for k in 0..4 { + let (x, rest) = mat.split_at_mut(linidx(i, k) + 1); + let a = x.last_mut().unwrap(); + let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); + ::std::mem::swap(a, b); + } + } + } + } + assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); +} diff --git a/tests/ui/codegen/mismatched-data-layout.json b/tests/ui/codegen/mismatched-data-layout.json index f8c510c1863..a1b222010ab 100644 --- a/tests/ui/codegen/mismatched-data-layout.json +++ b/tests/ui/codegen/mismatched-data-layout.json @@ -3,7 +3,7 @@ "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", - "target-pointer-width": "64", + "target-pointer-width": 64, "os": "none", "linker-flavor": "ld.lld", "linker": "rust-lld", diff --git a/tests/ui/codegen/nested-enum-match-optimization-15793.rs b/tests/ui/codegen/nested-enum-match-optimization-15793.rs new file mode 100644 index 00000000000..420e3ad82b2 --- /dev/null +++ b/tests/ui/codegen/nested-enum-match-optimization-15793.rs @@ -0,0 +1,29 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/15793 + +//@ run-pass +#![allow(dead_code)] + +enum NestedEnum { + First, + Second, + Third +} +enum Enum { + Variant1(bool), + Variant2(NestedEnum) +} + +#[inline(never)] +fn foo(x: Enum) -> isize { + match x { + Enum::Variant1(true) => 1, + Enum::Variant1(false) => 2, + Enum::Variant2(NestedEnum::Second) => 3, + Enum::Variant2(NestedEnum::Third) => 4, + Enum::Variant2(NestedEnum::First) => 5 + } +} + +fn main() { + assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4); +} diff --git a/tests/ui/codegen/static-array-comparison-7012.rs b/tests/ui/codegen/static-array-comparison-7012.rs new file mode 100644 index 00000000000..c08b1c0059b --- /dev/null +++ b/tests/ui/codegen/static-array-comparison-7012.rs @@ -0,0 +1,23 @@ +// https://github.com/rust-lang/rust/issues/7012 +//@ run-pass +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +/* +# Comparison of static arrays + +The expected behaviour would be that `test == test1`, therefore 'true' +would be printed, however the below prints false. +*/ + +struct signature<'a> { pattern : &'a [u32] } + +static test1: signature<'static> = signature { + pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] +}; + +pub fn main() { + let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, + 0x03707344,0xa4093822,0x299f31d0]; + println!("{}",test==test1.pattern); +} |
