gccrs: Add execution test cases
[official-gcc.git] / gcc / testsuite / rust / execute / torture / trait10.rs
blobe581e324bbf7b67f73e3558dcc848801eb11faf7
1 /* { dg-output "123\n" } */
2 extern "C" {
3     fn printf(s: *const i8, ...);
6 struct Foo(i32);
7 trait Bar {
8     fn baz(&self);
11 impl Bar for Foo {
12     fn baz(&self) {
13         unsafe {
14             let a = "%i\n\0";
15             let b = a as *const str;
16             let c = b as *const i8;
18             printf(c, self.0);
19         }
20     }
23 struct S;
24 impl S {
25     fn dynamic_dispatch(self, t: &dyn Bar) {
26         // { dg-warning "unused name" "" { target *-*-* } .-1 }
27         t.baz();
28     }
31 pub fn main() -> i32 {
32     let a;
33     a = &Foo(123);
35     let b;
36     b = S;
38     b.dynamic_dispatch(a);
40     0