This is the mail archive of the binutils-cvs@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]

[binutils-gdb] gas 0b vs 0b0 vs 00b


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c14c7a8a619ce03a7c8f41d1cfac3af728df453b

commit c14c7a8a619ce03a7c8f41d1cfac3af728df453b
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 13 15:55:31 2015 +0930

    gas 0b vs 0b0 vs 00b
    
    	* expr.c (integer_constant): Return O_absent expression if eol.
    	(operand): For targets with both LOCAL_LABELS_FB and
    	NUMBERS_WITH_SUFFIX set, treat "0b" not followed by binary
    	digits as a local label reference.  Correct handling of 0b prefix.
    	If a suffix is not allowed, error on 0B.

Diff:
---
 gas/ChangeLog |  9 +++++++++
 gas/expr.c    | 44 +++++++++++++++++++++++---------------------
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index d5b29f2..9fa7032 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,4 +1,13 @@
 2015-08-13  Alan Modra  <amodra@gmail.com>
+	    DJ Delorie  <dj@redhat.com>
+
+	* expr.c (integer_constant): Return O_absent expression if eol.
+	(operand): For targets with both LOCAL_LABELS_FB and
+	NUMBERS_WITH_SUFFIX set, treat "0b" not followed by binary
+	digits as a local label reference.  Correct handling of 0b prefix.
+	If a suffix is not allowed, error on 0B.
+
+2015-08-13  Alan Modra  <amodra@gmail.com>
 
 	* doc/as.texinfo (Local Labels): Allowed range of N in local
 	labels is non-negative integers, not positive integers.
diff --git a/gas/expr.c b/gas/expr.c
index 106f06d..2dae6ba 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -285,6 +285,12 @@ integer_constant (int radix, expressionS *expressionP)
 #define valuesize 32
 #endif
 
+  if (is_end_of_line[(unsigned char) *input_line_pointer])
+    {
+      expressionP->X_op = O_absent;
+      return;
+    }
+
   if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) && radix == 0)
     {
       int flt = 0;
@@ -832,32 +838,28 @@ operand (expressionS *expressionP, enum expr_mode mode)
 	  break;
 
 	case 'b':
-	  if (LOCAL_LABELS_FB && ! (flag_m68k_mri || NUMBERS_WITH_SUFFIX))
+	  if (LOCAL_LABELS_FB && !flag_m68k_mri
+	      && input_line_pointer[1] != '0'
+	      && input_line_pointer[1] != '1')
 	    {
-	      /* This code used to check for '+' and '-' here, and, in
-		 some conditions, fall through to call
-		 integer_constant.  However, that didn't make sense,
-		 as integer_constant only accepts digits.  */
-	      /* Some of our code elsewhere does permit digits greater
-		 than the expected base; for consistency, do the same
-		 here.  */
-	      if (input_line_pointer[1] < '0'
-		  || input_line_pointer[1] > '9')
-		{
-		  /* Parse this as a back reference to label 0.  */
-		  input_line_pointer--;
-		  integer_constant (10, expressionP);
-		  break;
-		}
-	      /* Otherwise, parse this as a binary number.  */
+	      /* Parse this as a back reference to label 0.  */
+	      input_line_pointer--;
+	      integer_constant (10, expressionP);
+	      break;
 	    }
+	  /* Otherwise, parse this as a binary number.  */
 	  /* Fall through.  */
 	case 'B':
-	  input_line_pointer++;
+	  if (input_line_pointer[1] == '0'
+	      || input_line_pointer[1] == '1')
+	    {
+	      input_line_pointer++;
+	      integer_constant (2, expressionP);
+	      break;
+	    }
 	  if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
-	    goto default_case;
-	  integer_constant (2, expressionP);
-	  break;
+	    input_line_pointer++;
+	  goto default_case;
 
 	case '0':
 	case '1':


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