40 lines · c
1// RUN: not %clang_cc1 -fsyntax-only -fno-diagnostics-show-line-numbers -fmessage-length=75 -o /dev/null -x c < %s 2>&1 | FileCheck %s -strict-whitespace2// REQUIRES: utf8-capable-terminal3 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 is7// responsible to create the code snippet shorter than the message-length (in8// number of columns.)9//10// The error diagnostic message printer should be able to handle the non-ascii11// characters without any segmentation fault or assertion failure. If your12// changes to clang frontend crashes this case, it is likely that you are mixing13// column index with byte index which are two totally different concepts.14 15// NOTE: This file is encoded in UTF-8 and intentionally contains some16// non-ASCII characters.17 18__attribute__((format(printf, 1, 2)))19extern int printf(const char *fmt, ...);20 21void test1(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα αααα αααα αααα αααα22// CHECK: unknown type name 'Unknown'23// CHECK-NEXT: void test1(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα ααα...24// CHECK-NEXT: {{^ \^$}}25 26void test2(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα αααα αααα27 28// CHECK: unknown type name 'Unknown'29// CHECK-NEXT: void test2(Unknown* b); // αααα αααα αααα αααα αααα αααα αααα αααα αααα30// CHECK-NEXT: {{^ \^$}}31 32void test3() {33 /* αααα αααα αααα αααα αααα αααα αααα αααα αααα αααα */ printf("%d", "s");34}35// CHECK: format specifies type 'int' but the argument has36// CHECK: type 'char *'37// CHECK-NEXT: ...αααα αααα αααα αααα αααα αααα αααα αααα αααα */ printf("%d", "s");38// CHECK-NEXT: {{^ ~~ \^~~$}}39// CHECK-NEXT: {{^ %s$}}40