blob: 216b73dbfce29dcba13ee9800c693fe36cbc92d2 [file] [log] [blame]
Benjamin Kramer29f90e82012-07-12 08:20:49 +00001// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
Jordan Rose9dd82c12012-07-20 18:50:51 +00002// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s
Benjamin Kramer29f90e82012-07-12 08:20:49 +00003
4struct Foo {
5 int bar;
6};
7
Jordan Rose9dd82c12012-07-20 18:50:51 +00008// PR13312
Benjamin Kramer29f90e82012-07-12 08:20:49 +00009void test1() {
10 struct Foo foo;
Jordan Rose7f43ddd2013-01-24 20:50:46 +000011 foo.bar = 42
12// CHECK: error: non-ASCII characters are not allowed outside of literals and identifiers
13// CHECK: {{^ \^}}
Benjamin Kramer29f90e82012-07-12 08:20:49 +000014// CHECK: error: expected ';' after expression
15// Make sure we emit the fixit right in front of the snowman.
Jordan Rose7f43ddd2013-01-24 20:50:46 +000016// CHECK: {{^ \^}}
17// CHECK: {{^ ;}}
Jordan Rose9dd82c12012-07-20 18:50:51 +000018
Jordan Rosed4960d32013-01-24 21:19:51 +000019// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-8]]:15-[[@LINE-8]]:18}:""
20// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-9]]:15-[[@LINE-9]]:15}:";"
Jordan Rose9dd82c12012-07-20 18:50:51 +000021}
22
23
24int printf(const char *, ...);
25void 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.
34
Jordan Rose7f43ddd2013-01-24 20:50:46 +000035// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-9]]:16-[[@LINE-9]]:18}:"%ld"
Benjamin Kramer29f90e82012-07-12 08:20:49 +000036}
Jordan Rosee2fad6d2013-06-07 17:16:01 +000037
38void 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"
44
45 int ssss = 42;
46 int b = sss; // 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"
50
51 int sssssssss = 42;
52 int c = sssssssss; // expected-error{{use of undeclared identifier 'sssssssss'; did you mean 'sssssssssก'?}}
53// CHECK: {{^ \^}}
54// CHECK: {{^ sssssssss.+}}
55// CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:20}:"sssssssss\340\270\201"
56}