Skip to content

Commit

Permalink
make asm diagnostic instruction optional
Browse files Browse the repository at this point in the history
`DiagnosticInfoInlineAsm::getInstruction` may return a null pointer, so
the instruction shouldn't be blindly unwrapped.
  • Loading branch information
euclio committed Mar 24, 2019
1 parent 0633c55 commit 4728433
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/llvm/diagnostic.rs
Expand Up @@ -88,7 +88,7 @@ impl OptimizationDiagnostic<'ll> {
pub struct InlineAsmDiagnostic<'ll> {
pub cookie: c_uint,
pub message: &'ll Twine,
pub instruction: &'ll Value,
pub instruction: Option<&'ll Value>,
}

impl InlineAsmDiagnostic<'ll> {
Expand All @@ -107,7 +107,7 @@ impl InlineAsmDiagnostic<'ll> {
InlineAsmDiagnostic {
cookie,
message: message.unwrap(),
instruction: instruction.unwrap(),
instruction,
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-23458.rs
@@ -0,0 +1,10 @@
#![feature(asm)]

// only-x86_64

fn main() {
unsafe {
asm!("int $3"); //~ ERROR too few operands for instruction
//~| ERROR invalid operand in inline asm
}
}
17 changes: 17 additions & 0 deletions src/test/ui/issues/issue-23458.stderr
@@ -0,0 +1,17 @@
error: invalid operand in inline asm: 'int $3'
--> $DIR/issue-23458.rs:7:9
|
LL | asm!("int $3");
| ^^^^^^^^^^^^^^^

error: <inline asm>:1:2: error: too few operands for instruction
int
^

--> $DIR/issue-23458.rs:7:9
|
LL | asm!("int $3");
| ^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

0 comments on commit 4728433

Please sign in to comment.