From a29d8545b573d008e364571a83fcd865748a8ad8 Mon Sep 17 00:00:00 2001 From: John Kåre Alsaker Date: Thu, 16 Nov 2017 10:08:19 +0100 Subject: Make inline assembly volatile if it has no outputs. Fixes #46026 --- src/libsyntax_ext/asm.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libsyntax_ext') diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 3742fb8c804..d1de4dccd00 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -239,6 +239,12 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } + // If there are no outputs, the inline assembly is executed just for its side effects, + // so ensure that it is volatile + if outputs.is_empty() { + volatile = true; + } + MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprKind::InlineAsm(P(ast::InlineAsm { -- cgit 1.4.1-3-g733a5