[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
Tue Jul 9 03:38:44 PDT 2024


================
@@ -0,0 +1,52 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s 2>&1 -o %t | FileCheck %s --check-prefix=CHECK-WARN
+
+.string "abcdefg
+12345678"
+
+.ascii "some test ascii
+
+sequence
+with
+newlines
+"
+
+.asciz "another test string
+
+with
+newline characters
+
+
+"
+
+// CHECK-WARN:        warn-newline-in-string-constant.s:3:17: warning: unterminated string; newline inserted
+// CHECK-WARN:  .string "abcdefg
+
+// CHECK-WARN:   warn-newline-in-string-constant.s:6:24: warning: unterminated string; newline inserted
+// CHECK-WARN:  .ascii "some test ascii
+// CHECK-WARN:                         ^
----------------
s-barannikov wrote:

FileCheck is by default space-insensitive. If you want to test the location of a caret, you need to add `--strict-whitespace` argument.


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


More information about the llvm-commits mailing list