This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Missing error messages for Arm parse errors


I recently noticed that one of the arm operand parsing routines returned FAIL 
without setting inst.error. This results in gas silently accepting the 
malformed instruction.

Obviously it's preferable to have specific error messages, but it's an easy 
mistake to make, and silently generating wrong code is really bad. The patch 
below adds a catch-all "syntax error" to catch these cases.

Tested with cross to arm-none-eabi.
Ok?

2006-03-16  Paul Brook  <paul@codesourcery.com>

	* config/tc-arm.c (parse_operands): Set default error message.

Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.246
diff -u -p -r1.246 tc-arm.c
--- gas/config/tc-arm.c	10 Mar 2006 17:20:30 -0000	1.246
+++ gas/config/tc-arm.c	16 Mar 2006 00:09:32 -0000
@@ -4130,7 +4139,13 @@ parse_operands (char *str, const unsigne
 
     failure:
       if (!backtrack_pos)
-	return FAIL;
+	{
+	  /* The parse routine should already have set inst.error, but set a
+	     defaut here just in case.  */
+	  if (!inst.error)
+	    inst.error = _("syntax error");
+	  return FAIL;
+	}
 
       /* Do not backtrack over a trailing optional argument that
 	 absorbed some text.  We will only fail again, with the
@@ -4138,7 +4153,11 @@ parse_operands (char *str, const unsigne
 	 probably less helpful than the current one.  */
       if (backtrack_index == i && backtrack_pos != str
 	  && upat[i+1] == OP_stop)
-	return FAIL;
+	{
+	  if (!inst.error)
+	    inst.error = _("syntax error");
+	  return FAIL;
+	}
 
       /* Try again, skipping the optional argument at backtrack_pos.  */
       str = backtrack_pos;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]