rustc: Don't allow empty link_name when nolink attribute is present
Closes #1326
This commit is contained in:
parent
09869cd056
commit
6e1f9ad1f1
@ -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 @@ export fsync_fd;
|
||||
// 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 @@ export fsync_fd;
|
||||
// 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 @@ export fsync_fd;
|
||||
// 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::option;
|
||||
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;
|
||||
|
7
src/test/compile-fail/empty-linkname2.rs
Normal file
7
src/test/compile-fail/empty-linkname2.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// error-pattern:empty #[link_name] not allowed; use #[nolink].
|
||||
// Issue #1326
|
||||
|
||||
#[link_name = ""]
|
||||
#[nolink]
|
||||
native mod foo {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user