source-col-map.c 2.0 KB

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