提交 6e1f9ad1 编写于 作者: B Brian Anderson

rustc: Don't allow empty link_name when nolink attribute is present

Closes #1326
上级 09869cd0
......@@ -57,17 +57,20 @@ fn visit_item(e: env, i: @ast::item) {
}
let cstore = e.sess.get_cstore();
let native_name = i.ident;
let native_name =
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
some(nn) {
if nn == "" {
e.sess.span_fatal(
i.span,
"empty #[link_name] not allowed; use #[nolink].");
}
nn
}
none. { i.ident }
};
let already_added = false;
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u {
alt attr::get_meta_item_value_str_by_name(i.attrs, "link_name") {
some(nn) { native_name = nn; }
none. { }
}
if native_name == "" {
e.sess.span_fatal(i.span,
"empty #[link_name] not allowed; use #[nolink].");
}
already_added = !cstore::add_used_library(cstore, native_name);
}
let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
......
......@@ -24,7 +24,6 @@
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
// by https://github.com/graydon/rust/issues#issue/268
#[link_name = ""] // FIXME remove after #[nolink] is snapshotted
#[nolink]
#[abi = "cdecl"]
native mod libc {
......
......@@ -24,7 +24,6 @@
// FIXME Somehow merge stuff duplicated here and macosx_os.rs. Made difficult
// by https://github.com/graydon/rust/issues#issue/268
#[link_name = ""] // FIXME remove after #[nolink] is snapshotted
#[nolink]
#[abi = "cdecl"]
native mod libc {
......
......@@ -18,7 +18,6 @@
// FIXME Refactor into unix_os module or some such. Doesn't
// seem to work right now.
#[link_name = ""] // FIXME: Remove after snapshotting
#[nolink]
#[abi = "cdecl"]
native mod libc {
......
......@@ -2,7 +2,6 @@
import core::ctypes::*;
#[abi = "cdecl"]
#[link_name = ""] // FIXME remove after #[nolink] is snapshotted
#[nolink]
native mod libc {
fn read(fd: fd_t, buf: *u8, count: size_t) -> ssize_t;
......
// error-pattern:empty #[link_name] not allowed; use #[nolink].
// Issue #1326
#[link_name = ""]
#[nolink]
native mod foo {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册