Alexander Kornienko | 48c9900 | 2013-09-11 18:10:30 +0000 | [diff] [blame] | 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. |
| 4 | |
Rafael Espindola | 925213b | 2013-07-04 16:16:58 +0000 | [diff] [blame] | 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 |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 7 | |
| 8 | struct Foo { |
| 9 | int bar; |
| 10 | }; |
| 11 | |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 12 | // PR13312 |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 13 | void test1() { |
| 14 | struct Foo foo; |
Jordan Rose | 7f43ddd | 2013-01-24 20:50:46 +0000 | [diff] [blame] | 15 | foo.bar = 42☃ |
| 16 | // CHECK: error: non-ASCII characters are not allowed outside of literals and identifiers |
| 17 | // CHECK: {{^ \^}} |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 18 | // CHECK: error: expected ';' after expression |
| 19 | // Make sure we emit the fixit right in front of the snowman. |
Jordan Rose | 7f43ddd | 2013-01-24 20:50:46 +0000 | [diff] [blame] | 20 | // CHECK: {{^ \^}} |
| 21 | // CHECK: {{^ ;}} |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 22 | |
Alexander Kornienko | 48c9900 | 2013-09-11 18:10:30 +0000 | [diff] [blame] | 23 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-8]]:15-[[@LINE-8]]:18}:"" |
| 24 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-9]]:15-[[@LINE-9]]:15}:";" |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | |
| 28 | int printf(const char *, ...); |
| 29 | void test2() { |
| 30 | printf("∆: %d", 1L); |
| 31 | // CHECK: warning: format specifies type 'int' but the argument has type 'long' |
| 32 | // Don't crash emitting a fixit after the delta. |
| 33 | // CHECK: printf(" |
| 34 | // CHECK: : %d", 1L); |
| 35 | // Unfortunately, we can't actually check the location of the printed fixit, |
| 36 | // because different systems will render the delta differently (either as a |
| 37 | // character, or as <U+2206>.) The fixit should line up with the %d regardless. |
| 38 | |
Alexander Kornienko | 48c9900 | 2013-09-11 18:10:30 +0000 | [diff] [blame] | 39 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-9]]:16-[[@LINE-9]]:18}:"%ld" |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 40 | } |
Jordan Rose | e2fad6d | 2013-06-07 17:16:01 +0000 | [diff] [blame] | 41 | |
| 42 | void test3() { |
| 43 | int กssss = 42; |
| 44 | int a = กsss; // expected-error{{use of undeclared identifier 'กsss'; did you mean 'กssss'?}} |
| 45 | // CHECK: {{^ \^}} |
| 46 | // CHECK: {{^ [^ ]+ssss}} |
| 47 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:17}:"\340\270\201ssss" |
| 48 | |
| 49 | int ssกss = 42; |
| 50 | int b = ssกs; // expected-error{{use of undeclared identifier 'ssกs'; did you mean 'ssกss'?}} |
| 51 | // CHECK: {{^ \^}} |
| 52 | // CHECK: {{^ ss.+ss}} |
| 53 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:17}:"ss\340\270\201ss" |
| 54 | |
Alexander Kornienko | 48c9900 | 2013-09-11 18:10:30 +0000 | [diff] [blame] | 55 | int s一二三 = 42; |
| 56 | int b一二三四五六七 = ss一二三; // expected-error{{use of undeclared identifier 'ss一二三'; did you mean 's一二三'?}} |
| 57 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-1]]:32-[[@LINE-1]]:43}:"s\344\270\200\344\272\214\344\270\211" |
| 58 | |
| 59 | |
Jordan Rose | e2fad6d | 2013-06-07 17:16:01 +0000 | [diff] [blame] | 60 | int sssssssssก = 42; |
| 61 | int c = sssssssss; // expected-error{{use of undeclared identifier 'sssssssss'; did you mean 'sssssssssก'?}} |
| 62 | // CHECK: {{^ \^}} |
| 63 | // CHECK: {{^ sssssssss.+}} |
| 64 | // CHECK-MACHINE: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:20}:"sssssssss\340\270\201" |
| 65 | } |