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.
          || !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);
 
--- /dev/null
+# 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
 
--- /dev/null
+       .if 0
+# 1003 "cond-2.s"
+       .endif
+
+       .warning "line 5"
 
 
 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