aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2022-05-18 09:37:00 +0200
committerJan Beulich <jbeulich@suse.com>2022-05-18 09:37:00 +0200
commit43fe575c32f8d63e397280aa65e5fe39d587112e (patch)
tree18ed37cb49652a5e706e121f93bd6ecd29a5f8a0 /gas
parent2e55c34282273f69099bf90bc6d2f38959545e10 (diff)
downloadfsf-binutils-gdb-43fe575c32f8d63e397280aa65e5fe39d587112e.zip
fsf-binutils-gdb-43fe575c32f8d63e397280aa65e5fe39d587112e.tar.gz
fsf-binutils-gdb-43fe575c32f8d63e397280aa65e5fe39d587112e.tar.bz2
gas: don't ignore .linefile inside false conditionals
When assembling code previously pre-processed by a C compiler, long enough comments may have been collapsed into "# <line> <file>" constructs. If we skip these, line numbers (and possibly even file names) will be off / wrong in both diagnostics and debug info.
Diffstat (limited to 'gas')
-rw-r--r--gas/cond.c4
-rw-r--r--gas/testsuite/gas/all/cond-2.l12
-rw-r--r--gas/testsuite/gas/all/cond-2.s5
-rw-r--r--gas/testsuite/gas/all/gas.exp5
4 files changed, 26 insertions, 0 deletions
diff --git a/gas/cond.c b/gas/cond.c
index ee441e1..27977db 100644
--- a/gas/cond.c
+++ b/gas/cond.c
@@ -525,6 +525,10 @@ ignore_input (void)
|| !strncasecmp (s, "endc", 4))
return 0;
break;
+ case 'l': case 'L':
+ if (!strncasecmp (s, "linefile", 8))
+ return 0;
+ break;
}
return (current_cframe != NULL) && (current_cframe->ignoring);
diff --git a/gas/testsuite/gas/all/cond-2.l b/gas/testsuite/gas/all/cond-2.l
new file mode 100644
index 0000000..189c0de
--- /dev/null
+++ b/gas/testsuite/gas/all/cond-2.l
@@ -0,0 +1,12 @@
+# This should match the output of gas -al cond-2.s.
+.*: Assembler messages:
+.*:1005: Warning: line 5
+.*cond-2.s.*
+
+
+[ ]*[1-9][0-9]*[ ]+\.if[ ]+0[ ]*
+[ ]*[1-9][0-9]*[ ]+# 1003 "cond-2\.s"
+[ ]*[1-9][0-9]*[ ]+\.endif[ ]*
+[ ]*[1-9][0-9]*[ ]*
+[ ]*[1-9][0-9]*[ ]+\.warning[ ].*
+#pass
diff --git a/gas/testsuite/gas/all/cond-2.s b/gas/testsuite/gas/all/cond-2.s
new file mode 100644
index 0000000..5b8166c
--- /dev/null
+++ b/gas/testsuite/gas/all/cond-2.s
@@ -0,0 +1,5 @@
+ .if 0
+# 1003 "cond-2.s"
+ .endif
+
+ .warning "line 5"
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index ae7957b..1b87cf2 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -461,6 +461,11 @@ if [is_elf_format] {
run_dump_test quoted-sym-names
+# Targets where # is not a line comment character don't transform
+# "# <line> <file>" into .linefile (PR gas/29120).
+setup_xfail "tic30-*-*"
+run_list_test cond-2 "-al"
+
run_list_test macro "-alm"
run_list_test pr20312