rust/compiler/rustc_codegen_gcc/tests/run/static.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.1 KiB
Rust
Raw Normal View History

2020-05-10 10:54:30 -04:00
// Compiler:
//
// Run-time:
// status: 0
// stdout: 10
// 14
// 1
// 12
// 12
// 1
#![feature(no_core)]
2020-05-10 10:54:30 -04:00
#![no_std]
#![no_core]
#![no_main]
2020-05-10 10:54:30 -04:00
extern crate mini_core;
use mini_core::*;
2020-05-10 10:54:30 -04:00
struct Test {
field: isize,
}
struct WithRef {
refe: &'static Test,
}
static mut CONSTANT: isize = 10;
static mut TEST: Test = Test { field: 12 };
2020-05-10 10:54:30 -04:00
static mut TEST2: Test = Test { field: 14 };
2020-05-10 10:54:30 -04:00
static mut WITH_REF: WithRef = WithRef { refe: unsafe { &TEST } };
2020-05-10 10:54:30 -04:00
#[no_mangle]
2025-03-27 15:28:31 -04:00
extern "C" fn main(argc: isize, _argv: *const *const u8) -> i32 {
2020-05-10 10:54:30 -04:00
unsafe {
libc::printf(b"%ld\n\0" as *const u8 as *const i8, CONSTANT);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST2.field);
TEST2.field = argc;
libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST2.field);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, WITH_REF.refe.field);
WITH_REF.refe = &TEST2;
libc::printf(b"%ld\n\0" as *const u8 as *const i8, TEST.field);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, WITH_REF.refe.field);
}
0
}