diff options
Diffstat (limited to 'gcc')
24 files changed, 260 insertions, 162 deletions
diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs index ac24791..9fa5222 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_cfg.rs @@ -9,10 +9,14 @@ extern "C" { } fn print(s: &str) { - printf("%s\n" as *const str as *const i8, s as *const str as *const i8); + unsafe { + printf( + "%s\n" as *const str as *const i8, + s as *const str as *const i8, + ); + } } - fn main() -> i32 { let cfg = cfg!(A); if cfg { diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_concat.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_concat.rs index ca40585..555d49c 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_concat.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_concat.rs @@ -8,7 +8,12 @@ extern "C" { } fn print(s: &str) { - printf("%s\n" as *const str as *const i8, s as *const str as *const i8); + unsafe { + printf( + "%s\n" as *const str as *const i8, + s as *const str as *const i8, + ); + } } fn main() -> i32 { diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_env.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_env.rs index ab6f139..211ddfc 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_env.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_env.rs @@ -10,7 +10,12 @@ extern "C" { } fn print(s: &str) { - printf("%s\n" as *const str as *const i8, s as *const str as *const i8); + unsafe { + printf( + "%s\n" as *const str as *const i8, + s as *const str as *const i8, + ); + } } fn main() -> i32 { diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs index 3f7ebd2..49da093 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs @@ -1,7 +1,7 @@ // { dg-output "104\n33\n1\n" } macro_rules! include_bytes { - () => {{}}; + () => {{}}; } extern "C" { @@ -10,35 +10,37 @@ extern "C" { fn print_int(value: i32) { let s = "%d\n\0" as *const str as *const i8; - printf(s, value); + unsafe { + printf(s, value); + } } fn main() -> i32 { - let bytes = include_bytes! ("include.txt"); - - print_int (bytes[0] as i32); - print_int (bytes[14] as i32); - - let the_bytes = b"hello, include!\n"; - - let x = bytes[0] == the_bytes[0] - && bytes[1] == the_bytes [1] - && bytes[2] == the_bytes [2] - && bytes[3] == the_bytes [3] - && bytes[4] == the_bytes [4] - && bytes[5] == the_bytes [5] - && bytes[6] == the_bytes [6] - && bytes[7] == the_bytes [7] - && bytes[8] == the_bytes [8] - && bytes[9] == the_bytes [9] - && bytes[10] == the_bytes [10] - && bytes[11] == the_bytes [11] - && bytes[12] == the_bytes [12] - && bytes[13] == the_bytes [13] - && bytes[14] == the_bytes [14] - && bytes[15] == the_bytes [15]; - - print_int (x as i32); - - 0 + let bytes = include_bytes!("include.txt"); + + print_int(bytes[0] as i32); + print_int(bytes[14] as i32); + + let the_bytes = b"hello, include!\n"; + + let x = bytes[0] == the_bytes[0] + && bytes[1] == the_bytes[1] + && bytes[2] == the_bytes[2] + && bytes[3] == the_bytes[3] + && bytes[4] == the_bytes[4] + && bytes[5] == the_bytes[5] + && bytes[6] == the_bytes[6] + && bytes[7] == the_bytes[7] + && bytes[8] == the_bytes[8] + && bytes[9] == the_bytes[9] + && bytes[10] == the_bytes[10] + && bytes[11] == the_bytes[11] + && bytes[12] == the_bytes[12] + && bytes[13] == the_bytes[13] + && bytes[14] == the_bytes[14] + && bytes[15] == the_bytes[15]; + + print_int(x as i32); + + 0 } diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_include_str.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_include_str.rs index 095d7cb..334b9c6 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_include_str.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_include_str.rs @@ -1,7 +1,7 @@ // { dg-output "hello, include!\n" } macro_rules! include_str { - () => {{}}; + () => {{}}; } extern "C" { @@ -9,15 +9,19 @@ extern "C" { } fn print(s: &str) { - printf("%s" as *const str as *const i8, s as *const str as *const i8); + unsafe { + printf( + "%s" as *const str as *const i8, + s as *const str as *const i8, + ); + } } - fn main() -> i32 { - // include_str! (and include_bytes!) allow for an optional trailing comma. - let my_str = include_str! ("include.txt",); + // include_str! (and include_bytes!) allow for an optional trailing comma. + let my_str = include_str!("include.txt",); - print (my_str); + print(my_str); - 0 + 0 } diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_line.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_line.rs index 873054d..6153bf5 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_line.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macro_line.rs @@ -1,10 +1,12 @@ -// { dg-output "15\n18\n" } +// { dg-output "17\n20\n" } extern "C" { fn printf(fmt: *const i8, ...); } fn print(s: u32) { - printf("%u\n\0" as *const str as *const i8, s); + unsafe { + printf("%u\n\0" as *const str as *const i8, s); + } } macro_rules! line { diff --git a/gcc/testsuite/rust/execute/torture/builtin_macros1.rs b/gcc/testsuite/rust/execute/torture/builtin_macros1.rs index d68f62f..6f52c37 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macros1.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macros1.rs @@ -8,7 +8,9 @@ extern "C" { } fn print(s: &str) { - printf("%s\n\0" as *const str as *const i8, s); + unsafe { + printf("%s\n\0" as *const str as *const i8, s); + } } fn main() -> i32 { diff --git a/gcc/testsuite/rust/execute/torture/builtin_macros3.rs b/gcc/testsuite/rust/execute/torture/builtin_macros3.rs index ed11780..6c0facb 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macros3.rs +++ b/gcc/testsuite/rust/execute/torture/builtin_macros3.rs @@ -8,7 +8,9 @@ extern "C" { } fn print(s: u32) { - printf("%u\n\0" as *const str as *const i8, s); + unsafe { + printf("%u\n\0" as *const str as *const i8, s); + } } fn main() -> i32 { @@ -21,4 +23,5 @@ fn main() -> i32 { print(c1); 0 -}
\ No newline at end of file +} + diff --git a/gcc/testsuite/rust/execute/torture/macros10.rs b/gcc/testsuite/rust/execute/torture/macros10.rs index f1fc34e..155a440 100644 --- a/gcc/testsuite/rust/execute/torture/macros10.rs +++ b/gcc/testsuite/rust/execute/torture/macros10.rs @@ -5,7 +5,9 @@ extern "C" { fn print_int(value: i32) { let s = "%d\n\0" as *const str as *const i8; - printf(s, value); + unsafe { + printf(s, value); + } } macro_rules! add_exprs { diff --git a/gcc/testsuite/rust/execute/torture/macros12.rs b/gcc/testsuite/rust/execute/torture/macros12.rs index ff4a862..d310dff 100644 --- a/gcc/testsuite/rust/execute/torture/macros12.rs +++ b/gcc/testsuite/rust/execute/torture/macros12.rs @@ -5,7 +5,9 @@ extern "C" { fn print_int(value: i32) { let s = "%d\n\0" as *const str as *const i8; - printf(s, value); + unsafe { + printf(s, value); + } } macro_rules! add_exprs { diff --git a/gcc/testsuite/rust/execute/torture/macros13.rs b/gcc/testsuite/rust/execute/torture/macros13.rs index af5dfe8..afb20264 100644 --- a/gcc/testsuite/rust/execute/torture/macros13.rs +++ b/gcc/testsuite/rust/execute/torture/macros13.rs @@ -5,7 +5,9 @@ extern "C" { fn print_int(value: i32) { let s = "%d\n\0" as *const str as *const i8; - printf(s, value); + unsafe { + printf(s, value); + } } macro_rules! add_exprs { diff --git a/gcc/testsuite/rust/execute/torture/macros14.rs b/gcc/testsuite/rust/execute/torture/macros14.rs index 2dc95e3..0065654 100644 --- a/gcc/testsuite/rust/execute/torture/macros14.rs +++ b/gcc/testsuite/rust/execute/torture/macros14.rs @@ -5,7 +5,9 @@ extern "C" { fn print_int(value: i32) { let s = "%d\n\0" as *const str as *const i8; - printf(s, value); + unsafe { + printf(s, value); + } } macro_rules! add_exprs { diff --git a/gcc/testsuite/rust/execute/torture/macros22.rs b/gcc/testsuite/rust/execute/torture/macros22.rs index 973af23..3f291ac 100644 --- a/gcc/testsuite/rust/execute/torture/macros22.rs +++ b/gcc/testsuite/rust/execute/torture/macros22.rs @@ -1,9 +1,11 @@ // { dg-output "1\n2\nNaN\n3\n" } macro_rules! print_num { - ($l:literal) => { - printf("%d\n\0" as *const str as *const i8, $l); - }; + ($l:literal) => {{ + unsafe { + printf("%d\n\0" as *const str as *const i8, $l); + } + }}; } extern "C" { @@ -15,7 +17,9 @@ fn main() -> i32 { print_num!(1); print_num!(2); - printf("NaN\n\0" as *const str as *const i8); + unsafe { + printf("NaN\n\0" as *const str as *const i8); + } print_num!(3); diff --git a/gcc/testsuite/rust/execute/torture/macros29.rs b/gcc/testsuite/rust/execute/torture/macros29.rs index 7bce29b..506d660 100644 --- a/gcc/testsuite/rust/execute/torture/macros29.rs +++ b/gcc/testsuite/rust/execute/torture/macros29.rs @@ -1,21 +1,23 @@ // { dg-output "1\n" } macro_rules! concat { - () => {{}}; + () => {{}}; } extern "C" { - fn printf(fmt: *const i8, ...); + fn printf(fmt: *const i8, ...); } fn print(s: u32) { - printf("%u\n\0" as *const str as *const i8, s); + unsafe { + printf("%u\n\0" as *const str as *const i8, s); + } } -fn main () -> i32 { - let res = concat!("test2") == "test3"; - if !res { - print(1); - } +fn main() -> i32 { + let res = concat!("test2") == "test3"; + if !res { + print(1); + } - 0 + 0 } diff --git a/gcc/testsuite/rust/execute/torture/macros30.rs b/gcc/testsuite/rust/execute/torture/macros30.rs index 09247e6..8f54b05 100644 --- a/gcc/testsuite/rust/execute/torture/macros30.rs +++ b/gcc/testsuite/rust/execute/torture/macros30.rs @@ -1,22 +1,24 @@ // { dg-output "1\n" } macro_rules! concat { - () => {{}}; + () => {{}}; } extern "C" { - fn printf(fmt: *const i8, ...); + fn printf(fmt: *const i8, ...); } fn print(s: u32) { - printf("%u\n\0" as *const str as *const i8, s); + unsafe { + printf("%u\n\0" as *const str as *const i8, s); + } } -fn main () -> i32 { - let mut x = concat!("x"); - x = concat!("y"); - if x == "y" { - print(1); - } +fn main() -> i32 { + let mut x = concat!("x"); + x = concat!("y"); + if x == "y" { + print(1); + } - 0 + 0 } diff --git a/gcc/testsuite/rust/execute/torture/macros31.rs b/gcc/testsuite/rust/execute/torture/macros31.rs index 1a67c47..6ad6d7e 100644 --- a/gcc/testsuite/rust/execute/torture/macros31.rs +++ b/gcc/testsuite/rust/execute/torture/macros31.rs @@ -9,10 +9,14 @@ extern "C" { } fn print(s: &str) { - printf("%s\n" as *const str as *const i8, s as *const str as *const i8); + unsafe { + printf( + "%s\n" as *const str as *const i8, + s as *const str as *const i8, + ); + } } - fn main() -> i32 { let cfg = cfg!(A) || cfg!(B); if cfg { diff --git a/gcc/testsuite/rust/execute/torture/match_bool1.rs b/gcc/testsuite/rust/execute/torture/match_bool1.rs index 45900b8..101dbb5 100644 --- a/gcc/testsuite/rust/execute/torture/match_bool1.rs +++ b/gcc/testsuite/rust/execute/torture/match_bool1.rs @@ -4,41 +4,46 @@ extern "C" { fn printf(s: *const i8, ...); } -fn foo (x: bool) -> i32 { +fn foo(x: bool) -> i32 { match x { - true => { return 182; }, - false => { return 55; }, + true => { + return 182; + } + false => { + return 55; + } } } -fn bar (y: i32) { - +fn bar(y: i32) { match y < 100 { true => { let a = "%i is less than 100\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c, y); + unsafe { + printf(c, y); + } } _ => { let a = "%i is more than 100\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c, y); + unsafe { + printf(c, y); + } } } } +fn main() -> i32 { + let a = foo(true); + let b = foo(false); -fn main () -> i32 { - - let a = foo (true); - let b = foo (false); - - bar (a); - bar (b); + bar(a); + bar(b); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_byte1.rs b/gcc/testsuite/rust/execute/torture/match_byte1.rs index 3d09a33..3546cfb 100644 --- a/gcc/testsuite/rust/execute/torture/match_byte1.rs +++ b/gcc/testsuite/rust/execute/torture/match_byte1.rs @@ -4,46 +4,53 @@ extern "C" { fn printf(s: *const i8, ...); } -fn foo (x: u8) { +fn foo(x: u8) { match x { b'a' => { let a = "a\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } b'\x07' => { let a = "seven\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } b'\'' => { let a = "quote\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "else\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn main () -> i32 { - +fn main() -> i32 { let x: u8 = 7; - foo (b'a'); - foo (x); - foo (b'\''); - foo (b'\\'); + foo(b'a'); + foo(x); + foo(b'\''); + foo(b'\\'); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_char1.rs b/gcc/testsuite/rust/execute/torture/match_char1.rs index e9da8ff..fa65876a 100644 --- a/gcc/testsuite/rust/execute/torture/match_char1.rs +++ b/gcc/testsuite/rust/execute/torture/match_char1.rs @@ -4,46 +4,53 @@ extern "C" { fn printf(s: *const i8, ...); } -fn foo (x: char) { +fn foo(x: char) { match x { 'a' => { let a = "amazing\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } 'c' => { let a = "compiler\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } 'p' => { let a = "productivity\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "wildcard\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn main () -> i32 { - +fn main() -> i32 { let p = 'p'; - foo ('a'); - foo ('b'); - foo ('c'); - foo (p); + foo('a'); + foo('b'); + foo('c'); + foo(p); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_int1.rs b/gcc/testsuite/rust/execute/torture/match_int1.rs index b1373bf..209429a 100644 --- a/gcc/testsuite/rust/execute/torture/match_int1.rs +++ b/gcc/testsuite/rust/execute/torture/match_int1.rs @@ -4,91 +4,106 @@ extern "C" { fn printf(s: *const i8, ...); } -fn foo_i32 (x: i32) { +fn foo_i32(x: i32) { match x { 15 => { let a = "fifteen!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "other!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn foo_isize (x: isize) { +fn foo_isize(x: isize) { match x { 15 => { let a = "fifteen!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "other!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn foo_u32 (x: u32) { +fn foo_u32(x: u32) { match x { 15 => { let a = "fifteen!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "other!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn foo_usize (x: usize) { +fn foo_usize(x: usize) { match x { 15 => { let a = "fifteen!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "other!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } - -fn main () -> i32 { +fn main() -> i32 { let x = -2; - foo_i32 (x); - foo_i32 (334); - foo_isize (-4768); - foo_isize (15); + foo_i32(x); + foo_i32(334); + foo_isize(-4768); + foo_isize(15); let y = 127; - foo_u32 (15); - foo_u32 (y); - foo_usize (2394); - foo_usize (15); + foo_u32(15); + foo_u32(y); + foo_usize(2394); + foo_usize(15); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_loop1.rs b/gcc/testsuite/rust/execute/torture/match_loop1.rs index d3aab6b..bb6aee9 100644 --- a/gcc/testsuite/rust/execute/torture/match_loop1.rs +++ b/gcc/testsuite/rust/execute/torture/match_loop1.rs @@ -7,10 +7,10 @@ extern "C" { enum E { One, Two, - Other + Other, } -fn foo () { +fn foo() { let mut x = E::One; loop { @@ -19,7 +19,9 @@ fn foo () { let a = "E::One\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } x = E::Two; } @@ -27,7 +29,9 @@ fn foo () { let a = "E::Two\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } x = E::Other; } @@ -35,7 +39,9 @@ fn foo () { let a = "break!\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } break; } @@ -43,9 +49,8 @@ fn foo () { } } - -fn main () -> i32 { - foo (); +fn main() -> i32 { + foo(); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_range1.rs b/gcc/testsuite/rust/execute/torture/match_range1.rs index 8fe8f4c..82e9e34 100644 --- a/gcc/testsuite/rust/execute/torture/match_range1.rs +++ b/gcc/testsuite/rust/execute/torture/match_range1.rs @@ -6,29 +6,32 @@ extern "C" { const END_RANGE: i32 = 15; -fn foo (x: i32) { +fn foo(x: i32) { match x { 0..=END_RANGE => { let a = "zero to END_RANGE\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "else\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn main () -> i32 { - - foo (11); - foo (15); - foo (21); +fn main() -> i32 { + foo(11); + foo(15); + foo(21); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_range2.rs b/gcc/testsuite/rust/execute/torture/match_range2.rs index 82980c2..8153f9e 100644 --- a/gcc/testsuite/rust/execute/torture/match_range2.rs +++ b/gcc/testsuite/rust/execute/torture/match_range2.rs @@ -7,34 +7,39 @@ extern "C" { const BIG_A: char = 'A'; const BIG_Z: char = 'Z'; -fn bar (x: char) { +fn bar(x: char) { match x { - 'a'..='z' => { let a = "lowercase\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } BIG_A..=BIG_Z => { let a = "uppercase\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } _ => { let a = "other\n\0"; let b = a as *const str; let c = b as *const i8; - printf (c); + unsafe { + printf(c); + } } } } -fn main () -> i32 { - bar ('b'); - bar ('X'); - bar ('!'); +fn main() -> i32 { + bar('b'); + bar('X'); + bar('!'); 0 } diff --git a/gcc/testsuite/rust/execute/torture/match_tuple1.rs b/gcc/testsuite/rust/execute/torture/match_tuple1.rs index 1874062..cb61cc0 100644 --- a/gcc/testsuite/rust/execute/torture/match_tuple1.rs +++ b/gcc/testsuite/rust/execute/torture/match_tuple1.rs @@ -30,12 +30,16 @@ fn inspect(f: Foo, g: u8) -> i32 { return 25; } -fn main () -> i32 { - let x = inspect (Foo::B, 2); - let y = inspect (Foo::B, 1); +fn main() -> i32 { + let x = inspect(Foo::B, 2); + let y = inspect(Foo::B, 1); - printf ("x:%d\n" as *const str as *const i8, x); - printf ("y:%d\n" as *const str as *const i8, y); + unsafe { + printf("x:%d\n" as *const str as *const i8, x); + } + unsafe { + printf("y:%d\n" as *const str as *const i8, y); + } y - x - 5 } |