gas: use get_single_number() in get_linefile_number()

Message ID ae42ff5a-b34e-4cbb-ae52-9afb59275c6c@suse.com
State New
Headers
Series gas: use get_single_number() in get_linefile_number() |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm fail Test failed

Commit Message

Jan Beulich Feb. 20, 2026, 3:12 p.m. UTC
  We don't really want to handle expressions there, we want plain numbers.
  

Patch

--- a/gas/read.c
+++ b/gas/read.c
@@ -2047,11 +2047,11 @@  s_file (int ignore ATTRIBUTE_UNUSED)
 static bool
 get_linefile_number (int *flag)
 {
-  expressionS exp;
+  offsetT val;
 
   SKIP_WHITESPACE ();
 
-  if (*input_line_pointer < '0' || *input_line_pointer > '9')
+  if (is_end_of_stmt (*input_line_pointer))
     return false;
 
   /* Don't mistakenly interpret octal numbers as line numbers.  */
@@ -2062,16 +2062,17 @@  get_linefile_number (int *flag)
       return true;
     }
 
-  expression_and_evaluate (&exp);
-  if (exp.X_op != O_constant)
+  val = get_single_number ();
+  /* Zero was handled above; getting back zero indicates an error.  */
+  if (val == 0)
     return false;
 
 #if defined (BFD64) || LONG_MAX > INT_MAX
-  if (exp.X_add_number < INT_MIN || exp.X_add_number > INT_MAX)
+  if (val < INT_MIN || val > INT_MAX)
     return false;
 #endif
 
-  *flag = exp.X_add_number;
+  *flag = val;
 
   return true;
 }
--- a/gas/testsuite/gas/all/linefile.l
+++ b/gas/testsuite/gas/all/linefile.l
@@ -1,6 +1,7 @@ 
 # This should match the output of gas linefile.s.
 .*linefile\.s: Assembler messages:
 .*linefile\.s:2: Warning: line 2
+.*linefile\.s:4: Error: .*
 .*linefile\.s:5: Warning: line 5
 .*linefile\.s:8: Warning: line 8
 #pass