From c14c7a8a619ce03a7c8f41d1cfac3af728df453b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 13 Aug 2015 15:55:31 +0930 Subject: [PATCH] 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. --- gas/ChangeLog | 9 +++++++++ gas/expr.c | 44 +++++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index d5b29f2ee10..9fa703255a7 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2015-08-13 Alan Modra + DJ Delorie + + * 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 * doc/as.texinfo (Local Labels): Allowed range of N in local diff --git a/gas/expr.c b/gas/expr.c index 106f06db21f..2dae6bacce0 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': -- 2.30.2