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.
This commit is contained in:
Alan Modra 2015-08-13 15:55:31 +09:30
parent 9791c25049
commit c14c7a8a61
2 changed files with 32 additions and 21 deletions

View File

@ -1,3 +1,12 @@
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> 2015-08-13 Alan Modra <amodra@gmail.com>
* doc/as.texinfo (Local Labels): Allowed range of N in local * doc/as.texinfo (Local Labels): Allowed range of N in local

View File

@ -285,6 +285,12 @@ integer_constant (int radix, expressionS *expressionP)
#define valuesize 32 #define valuesize 32
#endif #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) if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) && radix == 0)
{ {
int flt = 0; int flt = 0;
@ -832,17 +838,9 @@ operand (expressionS *expressionP, enum expr_mode mode)
break; break;
case 'b': case 'b':
if (LOCAL_LABELS_FB && ! (flag_m68k_mri || NUMBERS_WITH_SUFFIX)) if (LOCAL_LABELS_FB && !flag_m68k_mri
{ && input_line_pointer[1] != '0'
/* This code used to check for '+' and '-' here, and, in && input_line_pointer[1] != '1')
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. */ /* Parse this as a back reference to label 0. */
input_line_pointer--; input_line_pointer--;
@ -850,14 +848,18 @@ operand (expressionS *expressionP, enum expr_mode mode)
break; break;
} }
/* Otherwise, parse this as a binary number. */ /* Otherwise, parse this as a binary number. */
}
/* Fall through. */ /* Fall through. */
case 'B': case 'B':
if (input_line_pointer[1] == '0'
|| input_line_pointer[1] == '1')
{
input_line_pointer++; input_line_pointer++;
if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
goto default_case;
integer_constant (2, expressionP); integer_constant (2, expressionP);
break; break;
}
if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
input_line_pointer++;
goto default_case;
case '0': case '0':
case '1': case '1':