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