[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / FixIt / fixit-unicode.c
blob70c9751a2bcd69cd837406adbe8cb4154818a3e8
1 // This file contains code and checks, that should work on any platform.
2 // There's a set of additional checks for systems with proper support of UTF-8
3 // on the standard output in fixit-unicode-with-utf8-output.c.
5 // RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
6 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s
8 struct Foo {
9 int bar;
12 // PR13312
13 void test1() {
14 struct Foo foo;
15 foo.bar = 42
16 // CHECK: error: character <U+2603> not allowed in an identifier
17 // CHECK: {{^ \^}}
18 // Make sure we emit the fixit right in front of the snowman.
20 // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:18}:""
24 int printf(const char *, ...);
25 void test2() {
26 printf("∆: %d", 1L);
27 // CHECK: warning: format specifies type 'int' but the argument has type 'long'
28 // Don't crash emitting a fixit after the delta.
29 // CHECK: printf("
30 // CHECK: : %d", 1L);
31 // Unfortunately, we can't actually check the location of the printed fixit,
32 // because different systems will render the delta differently (either as a
33 // character, or as <U+2206>.) The fixit should line up with the %d regardless.
35 // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-9]]:16-[[@LINE-9]]:18}:"%ld"
38 void test3() {
39 int กssss = 42;
40 int a = กsss; // expected-error{{use of undeclared identifier 'กsss'; did you mean 'กssss'?}}
41 // CHECK: {{^ \^}}
42 // CHECK: {{^ [^ ]+ssss}}
43 // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:17}:"\340\270\201ssss"
45 int ssกss = 42;
46 int b = ssกs; // expected-error{{use of undeclared identifier 'ssกs'; did you mean 'ssกss'?}}
47 // CHECK: {{^ \^}}
48 // CHECK: {{^ ss.+ss}}
49 // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:17}:"ss\340\270\201ss"
51 int s一二三 = 42;
52 int b一二三四五六七 = ss一二三; // expected-error{{use of undeclared identifier 'ss一二三'; did you mean 's一二三'?}}
53 // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-1]]:32-[[@LINE-1]]:43}:"s\344\270\200\344\272\214\344\270\211"
56 int sssssssssก = 42;
57 int c = sssssssss; // expected-error{{use of undeclared identifier 'sssssssss'; did you mean 'sssssssssก'?}}
58 // CHECK: {{^ \^}}
59 // CHECK: {{^ sssssssss.+}}
60 // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:20}:"sssssssss\340\270\201"