diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-01-11 19:27:08 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-01-11 19:45:18 -0800 |
| commit | 6e1f9ad1f1b442d397bc120ed6916c4ddef2f4ae (patch) | |
| tree | fcbbd58ab4689d6e73502b86c5ba3c1b1f9e8a4d /src/comp/metadata | |
| parent | 09869cd0560c47f13c9740c121eac1a051b34bf4 (diff) | |
| download | rust-6e1f9ad1f1b442d397bc120ed6916c4ddef2f4ae.tar.gz rust-6e1f9ad1f1b442d397bc120ed6916c4ddef2f4ae.zip | |
rustc: Don't allow empty link_name when nolink attribute is present
Closes #1326
Diffstat (limited to 'src/comp/metadata')
| -rw-r--r-- | src/comp/metadata/creader.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs index 8c6204d1105..de7fe882aa1 100644 --- a/src/comp/metadata/creader.rs +++ b/src/comp/metadata/creader.rs @@ -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"); |
