[clang] [Clang] Wide delimiters ('{{{') for expect strings (PR #77326)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 8 10:46:13 PST 2024
================
@@ -157,3 +157,33 @@ unexpected b; // expected-error at 33 1-1 {{unknown type}}
// what-error {{huh?}}
// CHECK9: error: 'what-error' diagnostics expected but not seen:
#endif
+
+#ifdef TEST_WIDE_DELIM
+// RUN: not %clang_cc1 -DTEST_WIDE_DELIM -verify %s 2>&1 | FileCheck -check-prefix=CHECK-WIDE-DELIM %s
+
+// expected-error {{{some message with {{}} in it}}}
+// expected-error {{{some message with {}} in it}}}
+// expected-error {{{some message with {{} in it}}}
+
+// expected-error-re {{{some {{.*}} regex with double braces}}}
+// expected-error-re {{{some message with {{} in it}}}
+
+// expected-error {{{mismatched delim}}
+// expected-error-re {{{mismatched re {{.*} }}}
+// expected-error-re {{{no regex}}}
+
+#if 0
+// CHECK-WIDE-DELIM: error: 'expected-error' diagnostics expected but not seen:
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 164: some message with {{[{]{}[}]}} in it
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 165: some message with {}} in it
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 166: some message with {{[{]{[}]}} in it
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 168: {some {{.*}} regex with double braces
+// CHECK-WIDE-DELIM-NEXT: error: 'expected-error' diagnostics seen but not expected:
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 169: cannot find end ('}}') of expected regex
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 171: cannot find end ('}}}') of expected string
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 172: cannot find end ('}}') of expected regex
+// CHECK-WIDE-DELIM-NEXT: verify.c Line 173: cannot find start of regex ('{{[{][{]}}') in {no regex
----------------
sethp wrote:
This is probably confusing; it's `{no regex` because the delimiter is always `{{` in regex-mode, so the string is parsed like:
```
// expected-error-re {{{no regex}}}
|---------|^ trailing }
```
https://github.com/llvm/llvm-project/pull/77326
More information about the cfe-commits
mailing list