From 85aaf32e610e01ccde008e5bbfd6df95558dbeae Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 18 May 2022 09:38:40 +0200 Subject: [PATCH] gas: avoid octal numbers being accepted when processing .linefile Compilers would put decimal numbers there, so I think we should treat finding octal numbers the same as finding bignums - ignore them as actually being comments of some very specific form. --- gas/read.c | 8 ++++++++ gas/testsuite/gas/all/linefile.l | 1 + gas/testsuite/gas/all/linefile.s | 3 +++ 3 files changed, 12 insertions(+) diff --git a/gas/read.c b/gas/read.c index 8524d0bffb9..704e6f13569 100644 --- a/gas/read.c +++ b/gas/read.c @@ -2047,6 +2047,14 @@ get_linefile_number (int *flag) if (*input_line_pointer < '0' || *input_line_pointer > '9') return false; + /* Don't mistakenly interpret octal numbers as line numbers. */ + if (*input_line_pointer == '0') + { + *flag = 0; + ++input_line_pointer; + return true; + } + expression_and_evaluate (&exp); if (exp.X_op != O_constant) return false; diff --git a/gas/testsuite/gas/all/linefile.l b/gas/testsuite/gas/all/linefile.l index 7a5f700d061..089f328eadc 100644 --- a/gas/testsuite/gas/all/linefile.l +++ b/gas/testsuite/gas/all/linefile.l @@ -2,4 +2,5 @@ .*linefile\.s: Assembler messages: .*linefile\.s:2: Warning: line 2 .*linefile\.s:5: Warning: line 5 +.*linefile\.s:8: Warning: line 8 #pass diff --git a/gas/testsuite/gas/all/linefile.s b/gas/testsuite/gas/all/linefile.s index 4b34fee3b8f..ac0eb3f7516 100644 --- a/gas/testsuite/gas/all/linefile.s +++ b/gas/testsuite/gas/all/linefile.s @@ -3,3 +3,6 @@ # 123456789123456789123456789 "LINEfile.s" .warning "line 5" + +# 0123456789 "lineFILE.s" + .warning "line 8" -- 2.30.2