RISC-V: Reject empty rouding mode and fence operand.
authorJim Wilson <jimw@sifive.com>
Thu, 23 Aug 2018 20:26:48 +0000 (13:26 -0700)
committerJim Wilson <jimw@sifive.com>
Thu, 23 Aug 2018 20:26:48 +0000 (13:26 -0700)
gas/
2018-08-23  Kito Cheng  <kito@andestech.com>
* config/tc-riscv.c (arg_lookup): Checking
length before look up.
* testsuite/gas/riscv/fence-fail.d: New file.
* testsuite/gas/riscv/fence-fail.l: Likewise.
* testsuite/gas/riscv/fence-fail.s: Likewise.
* testsuite/gas/riscv/rouding-fail.d: Likewise.
* testsuite/gas/riscv/rouding-fail.l: Likewise.
* testsuite/gas/riscv/rouding-fail.s: Likewise.

gas/ChangeLog
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/fence-fail.d [new file with mode: 0644]
gas/testsuite/gas/riscv/fence-fail.l [new file with mode: 0644]
gas/testsuite/gas/riscv/fence-fail.s [new file with mode: 0644]
gas/testsuite/gas/riscv/rouding-fail.d [new file with mode: 0644]
gas/testsuite/gas/riscv/rouding-fail.l [new file with mode: 0644]
gas/testsuite/gas/riscv/rouding-fail.s [new file with mode: 0644]

index a9325fb814cd4d1900a23162bf599a5e17971d40..42523c8a30f398487ba78a50f7c245c40283b9a8 100644 (file)
@@ -1,3 +1,14 @@
+2018-08-23  Kito Cheng  <kito@andestech.com>
+
+       * config/tc-riscv.c (arg_lookup): Checking
+       length before look up.
+       * testsuite/gas/riscv/fence-fail.d: New file.
+       * testsuite/gas/riscv/fence-fail.l: Likewise.
+       * testsuite/gas/riscv/fence-fail.s: Likewise.
+       * testsuite/gas/riscv/rouding-fail.d: Likewise.
+       * testsuite/gas/riscv/rouding-fail.l: Likewise.
+       * testsuite/gas/riscv/rouding-fail.s: Likewise.
+
 2018-08-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/23536
index 5ba997e6cad1d475a0012c9d1a047898ae6d314d..ee4b4f5b7e217b875c50991bb632794bd7d3ed06 100644 (file)
@@ -618,6 +618,9 @@ arg_lookup (char **s, const char *const *array, size_t size, unsigned *regnop)
   const char *p = strchr (*s, ',');
   size_t i, len = p ? (size_t)(p - *s) : strlen (*s);
 
+  if (len == 0)
+    return FALSE;
+
   for (i = 0; i < size; i++)
     if (array[i] != NULL && strncmp (array[i], *s, len) == 0)
       {
diff --git a/gas/testsuite/gas/riscv/fence-fail.d b/gas/testsuite/gas/riscv/fence-fail.d
new file mode 100644 (file)
index 0000000..05b158f
--- /dev/null
@@ -0,0 +1,3 @@
+#as: -march=rv32i
+#source: fence-fail.s
+#error-output: fence-fail.l
diff --git a/gas/testsuite/gas/riscv/fence-fail.l b/gas/testsuite/gas/riscv/fence-fail.l
new file mode 100644 (file)
index 0000000..0d0912d
--- /dev/null
@@ -0,0 +1,4 @@
+.*: Assembler messages:
+.*: Error: illegal operands `fence ,'
+.*: Error: illegal operands `fence w,'
+.*: Error: illegal operands `fence ,w'
diff --git a/gas/testsuite/gas/riscv/fence-fail.s b/gas/testsuite/gas/riscv/fence-fail.s
new file mode 100644 (file)
index 0000000..9ce460e
--- /dev/null
@@ -0,0 +1,4 @@
+target:
+       fence ,
+       fence w,
+       fence ,w
diff --git a/gas/testsuite/gas/riscv/rouding-fail.d b/gas/testsuite/gas/riscv/rouding-fail.d
new file mode 100644 (file)
index 0000000..3544507
--- /dev/null
@@ -0,0 +1,3 @@
+#as: -march=rv32ifd
+#source: rouding-fail.s
+#error-output: rouding-fail.l
diff --git a/gas/testsuite/gas/riscv/rouding-fail.l b/gas/testsuite/gas/riscv/rouding-fail.l
new file mode 100644 (file)
index 0000000..ea46e7c
--- /dev/null
@@ -0,0 +1,3 @@
+.*: Assembler messages:
+.*: Error: illegal operands `fadd.s fa1,fa1,fa1,'
+.*: Error: illegal operands `fadd.d fa1,fa1,fa1,'
diff --git a/gas/testsuite/gas/riscv/rouding-fail.s b/gas/testsuite/gas/riscv/rouding-fail.s
new file mode 100644 (file)
index 0000000..d18f53e
--- /dev/null
@@ -0,0 +1,3 @@
+target:
+       fadd.s fa1,fa1,fa1,
+       fadd.d fa1,fa1,fa1,