Fix PR gas/26001 (pdp11-*-*)
authorStephen Casner <casner@acm.org>
Thu, 28 May 2020 01:40:38 +0000 (18:40 -0700)
committerStephen Casner <casner@acm.org>
Thu, 28 May 2020 01:40:38 +0000 (18:40 -0700)
PR gas/26001
* gas/config/tc-pdp11.c (parse_reg): Distinguish register names from
symbols that begin with a register name.
* gas/testsuite/gas/pdp11/pdp11.exp: Add test of such symbols.
* gas/testsuite/gas/pdp11/pr26001.s: Likewise.
* gas/testsuite/gas/pdp11/pr26001.d: Likewise.

gas/ChangeLog
gas/config/tc-pdp11.c
gas/testsuite/gas/pdp11/pdp11.exp
gas/testsuite/gas/pdp11/pr26001.d [new file with mode: 0644]
gas/testsuite/gas/pdp11/pr26001.s [new file with mode: 0644]

index 0d1565f00d356389c4e2ce6155a5e48f2092184e..c0b3dc88036a31c6105b9529254dd7f121380d04 100644 (file)
@@ -1,3 +1,12 @@
+2020-05-27  Stephen Casner  <casner@acm.org>
+
+       PR gas/26001
+       * config/tc-pdp11.c (parse_reg): Distinguish register names from
+       symbols that begin with a register name.
+       * testsuite/gas/pdp11/pdp11.exp: Add test of such symbols.
+       * testsuite/gas/pdp11/pr26001.s: Likewise.
+       * testsuite/gas/pdp11/pr26001.d: Likewise.
+
 2020-05-27  Simon Cook  <simon.cook@embecosm.com>
 
         * config/tc-riscv.c (riscv_init_csr_hash): NULL initilize next
index d38a3cd6d2598fb2a9372c9f46ae0d1f755390b8..57daa0f5097e31ccc61bb0a1d9d74e6e6ca3888f 100644 (file)
@@ -358,8 +358,17 @@ parse_reg (char *str, struct pdp11_code *operand)
       str += 2;
     }
   else
-    operand->error = _("Bad register name");
+    {
+      operand->error = _("Bad register name");
+      return str;
+    }
 
+  if (ISALNUM (*str) || *str == '_' || *str == '.')
+    {
+      operand->error = _("Bad register name");
+      str -= 2;
+    }
+  
   return str;
 }
 
index e27dd0581c832f0554610d370da4a615b8a2a02d..65c6a052b1af7681e9cd05d1d296b69788dfab36 100644 (file)
@@ -23,4 +23,5 @@ if [expr [istarget "pdp11-*-*"]]  then {
     run_dump_test "absreloc"
     run_dump_test "pr14480"
     run_dump_test "pr23481"
+    run_dump_test "pr26001"
 }
diff --git a/gas/testsuite/gas/pdp11/pr26001.d b/gas/testsuite/gas/pdp11/pr26001.d
new file mode 100644 (file)
index 0000000..a6ccdef
--- /dev/null
@@ -0,0 +1,12 @@
+#name: PR 26001 - distinguish register names from symbols
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+00 <start>:
+[      ]+0:[   ]+09f7 fffc[    ]+jsr[  ]+pc, 0 <start>
+[      ]+4:[   ]+1037 0004[    ]+mov[  ]+r0, \$c <space>
+[      ]+8:[   ]+1dc1 0002[    ]+mov[  ]+\$e <r00f>, r1
+#pass
diff --git a/gas/testsuite/gas/pdp11/pr26001.s b/gas/testsuite/gas/pdp11/pr26001.s
new file mode 100644 (file)
index 0000000..44faa14
--- /dev/null
@@ -0,0 +1,9 @@
+       .text
+       .globl  sprintf
+start: jsr     pc,sprintf
+       mov     r0,space
+       mov     r00f,r1
+       .data
+space: .word   0
+r00f:  .word   0
+       .end