diff options
author | Jan Beulich <jbeulich@suse.com> | 2023-11-03 13:33:38 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2023-11-03 13:33:38 +0100 |
commit | 88bfe6ac8bcbaf1eb0c1e4be02c21a5c048b7335 (patch) | |
tree | edca1c070104d5998bc14a0ab320379aaa0393ab /gas/expr.c | |
parent | c76820a017db5f7267d3e86851af41dd8adcbebf (diff) | |
download | gdb-88bfe6ac8bcbaf1eb0c1e4be02c21a5c048b7335.zip gdb-88bfe6ac8bcbaf1eb0c1e4be02c21a5c048b7335.tar.gz gdb-88bfe6ac8bcbaf1eb0c1e4be02c21a5c048b7335.tar.bz2 |
gas: correct ignoring of C-style number suffixes
First of all the respective original changes didn't deal with just 0
having such a suffix - this needs additional logic outside of
integer_constant(). Further bogus suffixes having more than two L-s
were accepted, while valid suffixes with U following the L(s) weren't.
Finally respective tests were introduced for Sparc only.
Reviewed-by: Neal Frager <neal.frager@amd.com>
Diffstat (limited to 'gas/expr.c')
-rw-r--r-- | gas/expr.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -538,17 +538,26 @@ integer_constant (int radix, expressionS *expressionP) #ifndef tc_allow_U_suffix #define tc_allow_U_suffix 1 #endif + bool u_seen = !tc_allow_U_suffix; /* PR 19910: Look for, and ignore, a U suffix to the number. */ - if (tc_allow_U_suffix && (c == 'U' || c == 'u')) - c = * input_line_pointer++; + if (!u_seen && (c == 'U' || c == 'u')) + { + c = *input_line_pointer++; + u_seen = true; + } #ifndef tc_allow_L_suffix #define tc_allow_L_suffix 1 #endif /* PR 20732: Look for, and ignore, a L or LL suffix to the number. */ - if (tc_allow_L_suffix) - while (c == 'L' || c == 'l') + if (tc_allow_L_suffix && (c == 'L' || c == 'l')) + { c = * input_line_pointer++; + if (c == 'L' || c == 'l') + c = *input_line_pointer++; + if (!u_seen && (c == 'U' || c == 'u')) + c = *input_line_pointer++; + } if (small) { @@ -888,6 +897,19 @@ operand (expressionS *expressionP, enum expr_mode mode) input_line_pointer++; goto default_case; + case 'l': + case 'L': + /* Accept an L suffix to the zero. */ + if (tc_allow_L_suffix) + goto numeric; + goto default_case; + + case 'u': + case 'U': + /* Accept a U suffix to the zero. */ + if (!tc_allow_U_suffix) + goto default_case; + /* Fall through. */ case '0': case '1': case '2': @@ -896,6 +918,7 @@ operand (expressionS *expressionP, enum expr_mode mode) case '5': case '6': case '7': + numeric: integer_constant ((flag_m68k_mri || NUMBERS_WITH_SUFFIX) ? 0 : 8, expressionP); |