Skip to content

Commit fb5539b

Browse files
committed
Add tests
1 parent fc41d4b commit fb5539b

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

compiler/rustc_target/src/asm/riscv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{InlineAsmArch, InlineAsmType};
2-
use crate::spec::{Target, RelocModel};
2+
use crate::spec::{RelocModel, Target};
33
use rustc_data_structures::stable_set::FxHashSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::{sym, Symbol};

compiler/rustc_target/src/asm/x86.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{InlineAsmArch, InlineAsmType};
2-
use crate::spec::{Target, RelocModel};
2+
use crate::spec::{RelocModel, Target};
33
use rustc_data_structures::stable_set::FxHashSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::Symbol;

src/test/ui/asm/issue-85247.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// revisions: ropi rwpi
2+
3+
// [ropi] compile-flags: --target armv7-unknown-linux-gnueabihf -C relocation-model=ropi
4+
// [rwpi] compile-flags: --target armv7-unknown-linux-gnueabihf -C relocation-model=rwpi
5+
// [ropi] needs-llvm-components: arm
6+
// [rwpi] needs-llvm-components: arm
7+
// [ropi] build-pass
8+
9+
#![feature(no_core, lang_items, rustc_attrs)]
10+
#![no_core]
11+
#![crate_type = "rlib"]
12+
13+
#[rustc_builtin_macro]
14+
macro_rules! asm {
15+
() => {};
16+
}
17+
#[lang = "sized"]
18+
trait Sized {}
19+
20+
// R9 is reserved as the RWPI base register
21+
fn main() {
22+
unsafe {
23+
asm!("", out("r9") _);
24+
//[rwpi]~^ cannot use register `r9`
25+
}
26+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: cannot use register `r9`: the RWPI static base register (r9) cannot be used as an operand for inline asm
2+
--> $DIR/issue-85247.rs:23:18
3+
|
4+
LL | asm!("", out("r9") _);
5+
| ^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

src/test/ui/asm/issue-92378.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// compile-flags: --target armv5te-unknown-linux-gnueabi
2+
// needs-llvm-components: arm
3+
// build-pass
4+
5+
#![feature(no_core, lang_items, rustc_attrs, isa_attribute)]
6+
#![no_core]
7+
#![crate_type = "rlib"]
8+
9+
#[rustc_builtin_macro]
10+
macro_rules! asm {
11+
() => {};
12+
}
13+
#[lang = "sized"]
14+
trait Sized {}
15+
16+
// ARM uses R11 for the frame pointer, make sure R7 is usable.
17+
#[instruction_set(arm::a32)]
18+
pub fn arm() {
19+
unsafe {
20+
asm!("", out("r7") _);
21+
}
22+
}
23+
24+
// Thumb uses R7 for the frame pointer, make sure R11 is usable.
25+
#[instruction_set(arm::t32)]
26+
pub fn thumb() {
27+
unsafe {
28+
asm!("", out("r11") _);
29+
}
30+
}

0 commit comments

Comments
 (0)