public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* sh: uninitialised sh_operand_info.type in get_specific
@ 2023-07-27 14:09 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-07-27 14:09 UTC (permalink / raw)
  To: binutils

Seen when running gas/testsuite/gas/sh/err-at.s

	* config/tc-sh.c (get_operands): Always init operand type.
	* testsuite/gas/sh/err-at.s: Expect unnecessary extra errors.

diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index bc0380a4961..634d5dcde41 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -1222,6 +1222,10 @@ static char *
 get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
 {
   char *ptr = args;
+
+  operand[0].type = 0;
+  operand[1].type = 0;
+  operand[2].type = 0;
   if (info->arg[0])
     {
       /* The pre-processor will eliminate whitespace in front of '@'
@@ -1234,9 +1238,7 @@ get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
       if (info->arg[1])
 	{
 	  if (*ptr == ',')
-	    {
-	      ptr++;
-	    }
+	    ptr++;
 	  get_operand (&ptr, operand + 1);
 	  /* ??? Hack: psha/pshl have a varying operand number depending on
 	     the type of the first operand.  We handle this by having the
@@ -1247,28 +1249,11 @@ get_operands (sh_opcode_info *info, char *args, sh_operand_info *operand)
 	  if (info->arg[2] && operand[0].type != A_IMM)
 	    {
 	      if (*ptr == ',')
-		{
-		  ptr++;
-		}
+		ptr++;
 	      get_operand (&ptr, operand + 2);
 	    }
-	  else
-	    {
-	      operand[2].type = 0;
-	    }
-	}
-      else
-	{
-	  operand[1].type = 0;
-	  operand[2].type = 0;
 	}
     }
-  else
-    {
-      operand[0].type = 0;
-      operand[1].type = 0;
-      operand[2].type = 0;
-    }
   return ptr;
 }
 
diff --git a/gas/testsuite/gas/sh/err-at.s b/gas/testsuite/gas/sh/err-at.s
index 648ee94e140..af5d081c0ee 100644
--- a/gas/testsuite/gas/sh/err-at.s
+++ b/gas/testsuite/gas/sh/err-at.s
@@ -4,7 +4,9 @@
 start:
 	mov.l	r1,@r0		! ok
 	mov.l	r1,@(r0)	! { dg-error "syntax error" }
+! { dg-bogus "invalid operands for opcode" "" { xfail *-*-* } 6 }
 	mov.l	r1,@(r0,)	! { dg-error "syntax error" }
+! { dg-bogus "invalid operands for opcode" "" { xfail *-*-* } 8 }
 	mov.l	r1,@(r0,r0)	! ok
 	mov.l	r1,@(r0,r1)	! ok
 	mov.l	r1,@(r1,r0)	! { dg-error "must be" }

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-27 14:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-27 14:09 sh: uninitialised sh_operand_info.type in get_specific Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).