gccrs: Add execution test cases
[official-gcc.git] / gcc / testsuite / rust / execute / torture / issue-1249.rs
blob072204ea877c255e18fefdcfca8e5e5f318cc6a6
1 // { dg-options "-w" }
2 // { dg-output "1\n2\n" }
4 extern "C" {
5     fn printf(s: *const i8, ...);
8 trait T {
9     fn foo(&self);
12 impl dyn T {
13     fn bar(&self) {
14         unsafe {
15             let a = "1\n\0";
16             let b = a as *const str;
17             let c = b as *const i8;
18             printf(c);
19         }
20         self.foo()
21     }
24 struct S;
25 impl T for S {
26     fn foo(&self) {
27         unsafe {
28             let a = "2\n\0";
29             let b = a as *const str;
30             let c = b as *const i8;
31             printf(c);
32         }
33     }
36 pub fn main() -> i32 {
37     <dyn T>::bar(&S);
38     0