about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2015-07-13 11:35:00 -0700
committerHuon Wilson <dbau.pp+github@gmail.com>2015-08-17 10:57:18 -0700
commitc8b6d5b23cc8b2d43ece9f06252c7e98280fb8e5 (patch)
treef7440965a23467b40bd55227c4093cc7b27dc2fb /src/libsyntax
parente822a18ae7d55cefc332c6598a607cef0554ec77 (diff)
downloadrust-c8b6d5b23cc8b2d43ece9f06252c7e98280fb8e5.tar.gz
rust-c8b6d5b23cc8b2d43ece9f06252c7e98280fb8e5.zip
Implement `repr(simd)` as an alias for `#[simd]`.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/attr.rs5
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs2
-rw-r--r--src/libsyntax/feature_gate.rs20
3 files changed, 25 insertions, 2 deletions
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 5e16465b4d4..3de9ba51974 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -579,6 +579,7 @@ pub fn find_repr_attrs(diagnostic: &SpanHandler, attr: &Attribute) -> Vec<ReprAt
                             // Can't use "extern" because it's not a lexical identifier.
                             "C" => Some(ReprExtern),
                             "packed" => Some(ReprPacked),
+                            "simd" => Some(ReprSimd),
                             _ => match int_type_of_word(&word) {
                                 Some(ity) => Some(ReprInt(item.span, ity)),
                                 None => {
@@ -628,6 +629,7 @@ pub enum ReprAttr {
     ReprInt(Span, IntType),
     ReprExtern,
     ReprPacked,
+    ReprSimd,
 }
 
 impl ReprAttr {
@@ -636,7 +638,8 @@ impl ReprAttr {
             ReprAny => false,
             ReprInt(_sp, ity) => ity.is_ffi_safe(),
             ReprExtern => true,
-            ReprPacked => false
+            ReprPacked => false,
+            ReprSimd => true,
         }
     }
 }
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 1f4860b7ec1..f8f63e94ee5 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -739,7 +739,7 @@ fn find_repr_type_name(diagnostic: &SpanHandler,
     for a in type_attrs {
         for r in &attr::find_repr_attrs(diagnostic, a) {
             repr_type_name = match *r {
-                attr::ReprAny | attr::ReprPacked => continue,
+                attr::ReprAny | attr::ReprPacked | attr::ReprSimd => continue,
                 attr::ReprExtern => "i32",
 
                 attr::ReprInt(_, attr::SignedInt(ast::TyIs)) => "isize",
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 694a1a43f59..a12291161f7 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -177,6 +177,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
     // Allows macros to appear in the type position.
 
     ("type_macros", "1.3.0", Active),
+
+    // allow `repr(simd)`, and importing the various simd intrinsics
+    ("simd_basics", "1.3.0", Active),
 ];
 // (changing above list without updating src/doc/reference.md makes @cmr sad)
 
@@ -359,6 +362,7 @@ pub struct Features {
     pub allow_box: bool,
     pub allow_pushpop_unsafe: bool,
     pub simd_ffi: bool,
+    pub simd_basics: bool,
     pub unmarked_api: bool,
     pub negate_unsigned: bool,
     /// spans of #![feature] attrs for stable language features. for error reporting
@@ -388,6 +392,7 @@ impl Features {
             allow_box: false,
             allow_pushpop_unsafe: false,
             simd_ffi: false,
+            simd_basics: false,
             unmarked_api: false,
             negate_unsigned: false,
             declared_stable_lang_features: Vec::new(),
@@ -660,6 +665,20 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
                 if attr::contains_name(&i.attrs[..], "simd") {
                     self.gate_feature("simd", i.span,
                                       "SIMD types are experimental and possibly buggy");
+                    self.context.span_handler.span_warn(i.span,
+                                                        "the `#[simd]` attribute is deprecated, \
+                                                         use `#[repr(simd)]` instead");
+                }
+                for attr in &i.attrs {
+                    if attr.name() == "repr" {
+                        for item in attr.meta_item_list().unwrap_or(&[]) {
+                            if item.name() == "simd" {
+                                self.gate_feature("simd_basics", i.span,
+                                                  "SIMD types are experimental and possibly buggy");
+
+                            }
+                        }
+                    }
                 }
             }
 
@@ -892,6 +911,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler,
         allow_box: cx.has_feature("box_syntax"),
         allow_pushpop_unsafe: cx.has_feature("pushpop_unsafe"),
         simd_ffi: cx.has_feature("simd_ffi"),
+        simd_basics: cx.has_feature("simd_basics"),
         unmarked_api: cx.has_feature("unmarked_api"),
         negate_unsigned: cx.has_feature("negate_unsigned"),
         declared_stable_lang_features: accepted_features,