1 // Copyright 2015 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.
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.
11 /// Run over the whole crate and check for ExprInlineAsm.
12 /// Inline asm isn't allowed on virtual ISA based targets, so we reject it
18 use syntax::visit::Visitor;
21 pub fn check_crate(sess: &Session, krate: &ast::Crate) {
22 if sess.target.target.options.allow_asm { return; }
24 visit::walk_crate(&mut CheckNoAsm { sess: sess, }, krate);
27 #[derive(Copy, Clone)]
28 struct CheckNoAsm<'a> {
32 impl<'a, 'v> Visitor<'v> for CheckNoAsm<'a> {
33 fn visit_expr(&mut self, e: &ast::Expr) {
35 ast::ExprInlineAsm(_) => span_err!(self.sess, e.span, E0472,
36 "asm! is unsupported on this target"),
39 visit::walk_expr(self, e)