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

gas/expr.c: 0b vs 0b0 vs 00b

For targets with both NUMBERS_WITH_SUFFIX and LOCAL_LABELS_FB, there
is a parse ambiquity between various binary constants:

0b	backward reference
1b	binary value, suffix
0b1	binary value, prefix

The third will be parsed as 0b followed by "junk".  This patch checks
for 0b followed by further binary digits and bypasses the b-as-suffix

I don't think a generic test case would work, since it would have to
test expressions that are only valid on some targets.  Would one
target's test suffice, or should the test be duplicated across many

diff --git a/gas/expr.c b/gas/expr.c
index 106f06d..2237c02 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -854,7 +854,8 @@ operand (expressionS *expressionP, enum expr_mode mode)
 	  /* Fall through.  */
 	case 'B':
-	  if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
+	  if ((flag_m68k_mri || NUMBERS_WITH_SUFFIX)
+	      && (input_line_pointer[0] != '0' && input_line_pointer[0] != '1'))
 	    goto default_case;
 	  integer_constant (2, expressionP);

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