about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_target/src/target_features.rs8
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs (renamed from tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs)0
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr (renamed from tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr)2
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs12
-rw-r--r--tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr8
5 files changed, 25 insertions, 5 deletions
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index 69c8b9119ab..9c8c804e18c 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -963,12 +963,12 @@ impl Target {
                 // about what the intended ABI is.
                 match &*self.llvm_abiname {
                     "ilp32d" | "lp64d" => {
-                        // Requires d (which implies f), incompatible with e.
-                        FeatureConstraints { required: &["d"], incompatible: &["e"] }
+                        // Requires d (which implies f), incompatible with e and zfinx.
+                        FeatureConstraints { required: &["d"], incompatible: &["e", "zfinx"] }
                     }
                     "ilp32f" | "lp64f" => {
-                        // Requires f, incompatible with e.
-                        FeatureConstraints { required: &["f"], incompatible: &["e"] }
+                        // Requires f, incompatible with e and zfinx.
+                        FeatureConstraints { required: &["f"], incompatible: &["e", "zfinx"] }
                     }
                     "ilp32" | "lp64" => {
                         // Requires nothing, incompatible with e.
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs
index 215e64979f7..215e64979f7 100644
--- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.rs
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr
index bfe767e5ffb..84d27463b38 100644
--- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-e-d.stderr
@@ -1,5 +1,5 @@
 error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
-  --> $DIR/forbidden-hardfloat-target-feature-attribute.rs:10:18
+  --> $DIR/forbidden-hardfloat-target-feature-attribute-e-d.rs:10:18
    |
 LL | #[target_feature(enable = "d")]
    |                  ^^^^^^^^^^^^
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs
new file mode 100644
index 00000000000..d74f4a1d4b1
--- /dev/null
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs
@@ -0,0 +1,12 @@
+//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`.
+//@ compile-flags: --target=riscv64gc-unknown-linux-gnu --crate-type=lib
+//@ needs-llvm-components: riscv
+#![feature(no_core, lang_items, riscv_target_feature)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+#[target_feature(enable = "zdinx")]
+//~^ERROR: cannot be enabled with
+pub unsafe fn my_fun() {}
diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr
new file mode 100644
index 00000000000..af0e53f34f2
--- /dev/null
+++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute-f-zfinx.stderr
@@ -0,0 +1,8 @@
+error: target feature `zfinx` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI
+  --> $DIR/forbidden-hardfloat-target-feature-attribute-f-zfinx.rs:10:18
+   |
+LL | #[target_feature(enable = "zdinx")]
+   |                  ^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+