about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2021-04-04 17:44:46 +0100
committerAmanieu d'Antras <amanieu@gmail.com>2021-04-05 13:38:24 +0100
commitb1bcff0731f5ce5f9c2de2779b36f94b44946bc6 (patch)
tree3200a7de727e68fb1e9f1898f80c7bdc0ede7c13 /src/test
parentcbd6ec760453b333e86aac106f47fe9132498924 (diff)
downloadrust-b1bcff0731f5ce5f9c2de2779b36f94b44946bc6.tar.gz
rust-b1bcff0731f5ce5f9c2de2779b36f94b44946bc6.zip
Disallow the use of high byte registes as operands on x86_64
They are still allowed on x86 though.

Fixes #83495
Diffstat (limited to 'src/test')
-rw-r--r--src/test/assembly/asm/x86-types.rs9
-rw-r--r--src/test/ui/asm/bad-reg.rs2
-rw-r--r--src/test/ui/asm/bad-reg.stderr20
3 files changed, 20 insertions, 11 deletions
diff --git a/src/test/assembly/asm/x86-types.rs b/src/test/assembly/asm/x86-types.rs
index e0190d3bdae..b65b727d225 100644
--- a/src/test/assembly/asm/x86-types.rs
+++ b/src/test/assembly/asm/x86-types.rs
@@ -748,10 +748,11 @@ check_reg!(eax_f64 f64 "eax" "mov");
 // CHECK: #NO_APP
 check_reg!(eax_ptr ptr "eax" "mov");
 
-// CHECK-LABEL: ah_byte:
-// CHECK: #APP
-// CHECK: mov ah, ah
-// CHECK: #NO_APP
+// i686-LABEL: ah_byte:
+// i686: #APP
+// i686: mov ah, ah
+// i686: #NO_APP
+#[cfg(i686)]
 check_reg!(ah_byte i8 "ah" "mov");
 
 // CHECK-LABEL: xmm0_i32:
diff --git a/src/test/ui/asm/bad-reg.rs b/src/test/ui/asm/bad-reg.rs
index 016ea9329c4..da302b24876 100644
--- a/src/test/ui/asm/bad-reg.rs
+++ b/src/test/ui/asm/bad-reg.rs
@@ -37,6 +37,8 @@ fn main() {
         //~^ ERROR invalid register `mm0`: MMX registers are not currently supported as operands
         asm!("", in("k0") foo);
         //~^ ERROR invalid register `k0`: the k0 AVX mask register cannot be used as an operand
+        asm!("", in("ah") foo);
+        //~^ ERROR invalid register `ah`: high byte registers cannot be used as an operand
 
         // Explicit register conflicts
         // (except in/lateout which don't conflict)
diff --git a/src/test/ui/asm/bad-reg.stderr b/src/test/ui/asm/bad-reg.stderr
index c6b7d310dfa..2bfb4854c34 100644
--- a/src/test/ui/asm/bad-reg.stderr
+++ b/src/test/ui/asm/bad-reg.stderr
@@ -94,8 +94,14 @@ error: invalid register `k0`: the k0 AVX mask register cannot be used as an oper
 LL |         asm!("", in("k0") foo);
    |                  ^^^^^^^^^^^^
 
+error: invalid register `ah`: high byte registers cannot be used as an operand on x86_64
+  --> $DIR/bad-reg.rs:40:18
+   |
+LL |         asm!("", in("ah") foo);
+   |                  ^^^^^^^^^^^^
+
 error: register `al` conflicts with register `ax`
-  --> $DIR/bad-reg.rs:44:33
+  --> $DIR/bad-reg.rs:46:33
    |
 LL |         asm!("", in("eax") foo, in("al") bar);
    |                  -------------  ^^^^^^^^^^^^ register `al`
@@ -103,7 +109,7 @@ LL |         asm!("", in("eax") foo, in("al") bar);
    |                  register `ax`
 
 error: register `ax` conflicts with register `ax`
-  --> $DIR/bad-reg.rs:46:33
+  --> $DIR/bad-reg.rs:48:33
    |
 LL |         asm!("", in("rax") foo, out("rax") bar);
    |                  -------------  ^^^^^^^^^^^^^^ register `ax`
@@ -111,13 +117,13 @@ LL |         asm!("", in("rax") foo, out("rax") bar);
    |                  register `ax`
    |
 help: use `lateout` instead of `out` to avoid conflict
-  --> $DIR/bad-reg.rs:46:18
+  --> $DIR/bad-reg.rs:48:18
    |
 LL |         asm!("", in("rax") foo, out("rax") bar);
    |                  ^^^^^^^^^^^^^
 
 error: register `ymm0` conflicts with register `xmm0`
-  --> $DIR/bad-reg.rs:49:34
+  --> $DIR/bad-reg.rs:51:34
    |
 LL |         asm!("", in("xmm0") foo, in("ymm0") bar);
    |                  --------------  ^^^^^^^^^^^^^^ register `ymm0`
@@ -125,7 +131,7 @@ LL |         asm!("", in("xmm0") foo, in("ymm0") bar);
    |                  register `xmm0`
 
 error: register `ymm0` conflicts with register `xmm0`
-  --> $DIR/bad-reg.rs:51:34
+  --> $DIR/bad-reg.rs:53:34
    |
 LL |         asm!("", in("xmm0") foo, out("ymm0") bar);
    |                  --------------  ^^^^^^^^^^^^^^^ register `ymm0`
@@ -133,10 +139,10 @@ LL |         asm!("", in("xmm0") foo, out("ymm0") bar);
    |                  register `xmm0`
    |
 help: use `lateout` instead of `out` to avoid conflict
-  --> $DIR/bad-reg.rs:51:18
+  --> $DIR/bad-reg.rs:53:18
    |
 LL |         asm!("", in("xmm0") foo, out("ymm0") bar);
    |                  ^^^^^^^^^^^^^^
 
-error: aborting due to 18 previous errors
+error: aborting due to 19 previous errors