[binutils-gdb] gas: use get_single_number() in get_linefile_number()

Jan Beulich jbeulich@sourceware.org
Fri Feb 27 07:03:58 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=097423696e95e81141a1000ab43cc380c3417345

commit 097423696e95e81141a1000ab43cc380c3417345
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Feb 27 08:00:32 2026 +0100

    gas: use get_single_number() in get_linefile_number()
    
    We don't really want to handle expressions there, we want plain numbers.

Diff:
---
 gas/read.c                       | 13 +++++++------
 gas/testsuite/gas/all/linefile.l |  2 ++
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gas/read.c b/gas/read.c
index 5905865a19a..bac5bea544c 100644
--- 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;
 }
diff --git a/gas/testsuite/gas/all/linefile.l b/gas/testsuite/gas/all/linefile.l
index 089f328eadc..c0d7c403bf7 100644
--- a/gas/testsuite/gas/all/linefile.l
+++ b/gas/testsuite/gas/all/linefile.l
@@ -1,6 +1,8 @@
 # This should match the output of gas linefile.s.
 .*linefile\.s: Assembler messages:
+#?.*linefile\.s:1: Error: .*
 .*linefile\.s:2: Warning: line 2
+.*linefile\.s:4: Error: .*
 .*linefile\.s:5: Warning: line 5
 .*linefile\.s:8: Warning: line 8
 #pass


More information about the Binutils-cvs mailing list