Skip to content

Commit 55cf032

Browse files
committed
rollup merge of #20124: klutzy/pprust-asm
2 parents 941361b + 023572b commit 55cf032

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,11 +1787,7 @@ impl<'a> State<'a> {
17871787
}
17881788
}
17891789
ast::ExprInlineAsm(ref a) => {
1790-
if a.volatile {
1791-
try!(word(&mut self.s, "__volatile__ asm!"));
1792-
} else {
1793-
try!(word(&mut self.s, "asm!"));
1794-
}
1790+
try!(word(&mut self.s, "asm!"));
17951791
try!(self.popen());
17961792
try!(self.print_string(a.asm.get(), a.asm_str_style));
17971793
try!(self.word_space(":"));
@@ -1829,6 +1825,28 @@ impl<'a> State<'a> {
18291825
try!(s.print_string(co.get(), ast::CookedStr));
18301826
Ok(())
18311827
}));
1828+
1829+
let mut options = vec!();
1830+
if a.volatile {
1831+
options.push("volatile");
1832+
}
1833+
if a.alignstack {
1834+
options.push("alignstack");
1835+
}
1836+
if a.dialect == ast::AsmDialect::AsmIntel {
1837+
options.push("intel");
1838+
}
1839+
1840+
if options.len() > 0 {
1841+
try!(space(&mut self.s));
1842+
try!(self.word_space(":"));
1843+
try!(self.commasep(Inconsistent, &*options,
1844+
|s, &co| {
1845+
try!(s.print_string(co, ast::CookedStr));
1846+
Ok(())
1847+
}));
1848+
}
1849+
18321850
try!(self.pclose());
18331851
}
18341852
ast::ExprMac(ref m) => try!(self.print_mac(m, token::Paren)),

src/test/pretty/asm-options.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(asm)]
12+
13+
// pp-exact
14+
15+
pub fn main() {
16+
unsafe {
17+
asm!("" : : : : "volatile");
18+
asm!("" : : : : "alignstack");
19+
asm!("" : : : : "intel");
20+
}
21+
}

0 commit comments

Comments
 (0)