1 | // RUN: not %clang_cc1 -fsyntax-only -fmessage-length 75 -o /dev/null -x c < %s 2>&1 | FileCheck %s -strict-whitespace |
2 | // REQUIRES: utf8-capable-terminal |
3 | |
4 | // Test case for the text diagnostics source column conversion crash. |
5 | |
6 | // This test case tries to check the error diagnostic message printer, which is |
7 | // responsible to create the code snippet shorter than the message-length (in |
8 | // number of columns.) |
9 | // |
10 | // The error diagnostic message printer should be able to handle the non-ascii |
11 | // characters without any segmentation fault or assertion failure. If your |
12 | // changes to clang frontend crashes this case, it is likely that you are mixing |
13 | // column index with byte index which are two totally different concepts. |
14 | |
15 | // NOTE: This file is encoded in UTF-8 and intentionally contains some |
16 | // non-ASCII characters. |
17 | |
18 | __attribute__((format(printf, 1, 2))) |
19 | extern int printf(const char *fmt, ...); |
20 | |
21 | void test1(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα αααα αααα αααα αααα |
22 | // CHECK: unknown type name 'Unknown' |
23 | // CHECK-NEXT: void test1(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα ααα... |
24 | // CHECK-NEXT: {{^ \^$}} |
25 | |
26 | void test2(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα αααα αααα |
27 | |
28 | // CHECK: unknown type name 'Unknown' |
29 | // CHECK-NEXT: void test2(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα αααα αααα |
30 | // CHECK-NEXT: {{^ \^$}} |
31 | |
32 | void test3() { |
33 | /* αααα αααα αααα αααα αααα αααα αααα αααα αααα αααα */ printf("%d", "s"); |
34 | } |
35 | // CHECK: format specifies type 'int' but the argument has |
36 | // CHECK: type 'char *' |
37 | // CHECK-NEXT: ...αααα αααα αααα αααα αααα αααα αααα αααα αααα */ printf("%d", "s"); |
38 | // CHECK-NEXT: {{^ ~~ \^~~$}} |
39 | // CHECK-NEXT: {{^ %s$}} |
40 | |