Skip to content

Commit 023572b

Browse files
committed
pprust: Fix asm options
1 parent 34d6800 commit 023572b

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
@@ -1786,11 +1786,7 @@ impl<'a> State<'a> {
17861786
}
17871787
}
17881788
ast::ExprInlineAsm(ref a) => {
1789-
if a.volatile {
1790-
try!(word(&mut self.s, "__volatile__ asm!"));
1791-
} else {
1792-
try!(word(&mut self.s, "asm!"));
1793-
}
1789+
try!(word(&mut self.s, "asm!"));
17941790
try!(self.popen());
17951791
try!(self.print_string(a.asm.get(), a.asm_str_style));
17961792
try!(self.word_space(":"));
@@ -1828,6 +1824,28 @@ impl<'a> State<'a> {
18281824
try!(s.print_string(co.get(), ast::CookedStr));
18291825
Ok(())
18301826
}));
1827+
1828+
let mut options = vec!();
1829+
if a.volatile {
1830+
options.push("volatile");
1831+
}
1832+
if a.alignstack {
1833+
options.push("alignstack");
1834+
}
1835+
if a.dialect == ast::AsmDialect::AsmIntel {
1836+
options.push("intel");
1837+
}
1838+
1839+
if options.len() > 0 {
1840+
try!(space(&mut self.s));
1841+
try!(self.word_space(":"));
1842+
try!(self.commasep(Inconsistent, &*options,
1843+
|s, &co| {
1844+
try!(s.print_string(co, ast::CookedStr));
1845+
Ok(())
1846+
}));
1847+
}
1848+
18311849
try!(self.pclose());
18321850
}
18331851
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)