[llvm] [MC,ELF] Emit warning if a string constant contains newline char. (PR #98060)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 01:30:13 PDT 2024


================
@@ -0,0 +1,54 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64 %s 2>&1 -o /dev/null | FileCheck -DFILE=%s --strict-whitespace %s --implicit-check-not="{{[0-9]+:[0-9]+: warning: unterminated string}}" --check-prefix=CHECK-WARN
+
+.string "abcd\xFFefg
+12345678"
+
+// CHECK-WARN:   [[#@LINE-3]]:21: warning: unterminated string; newline inserted
+// CHECK-NEXT:  .string "abcd\xFFefg
+
+.ascii "some test ascii
+
+sequence
+with
+newlines\x0A
+"
+
+// CHECK-WARN:   [[#@LINE-7]]:24: warning: unterminated string; newline inserted
+// CHECK-NEXT:   .ascii "some test ascii
----------------
s-barannikov wrote:

These CHECK-NEXT directives check nothing because you explicitly renamed the default "CHECK" to "CHECK-WARN" by --check-prefix option. The correct directive would therefore be "CHECK-WARN-NEXT". 

--check-prefix is only useful when you have multiple RUN lines. Using it when you have single RUN line does not hurt, but is just redundant.

(I'm not sure it is worth checking what these -NEXT directives are supposed to check. I'd just remove them, but you can keep them if you like, just fix the spelling of the directives.)


https://github.com/llvm/llvm-project/pull/98060


More information about the llvm-commits mailing list