Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 2 | // RUN: %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] | 3 | |
| 4 | struct Foo { |
| 5 | int bar; |
| 6 | }; |
| 7 | |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 8 | // PR13312 |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 9 | void test1() { |
| 10 | struct Foo foo; |
Jordan Rose | 7f43ddd | 2013-01-24 20:50:46 +0000 | [diff] [blame^] | 11 | foo.bar = 42☃ |
| 12 | // CHECK: error: non-ASCII characters are not allowed outside of literals and identifiers |
| 13 | // CHECK: {{^ \^}} |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 14 | // CHECK: error: expected ';' after expression |
| 15 | // Make sure we emit the fixit right in front of the snowman. |
Jordan Rose | 7f43ddd | 2013-01-24 20:50:46 +0000 | [diff] [blame^] | 16 | // CHECK: {{^ \^}} |
| 17 | // CHECK: {{^ ;}} |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 18 | |
Jordan Rose | 7f43ddd | 2013-01-24 20:50:46 +0000 | [diff] [blame^] | 19 | // CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-8]]:15-[[@LINE-8]]:15}:";" |
Jordan Rose | 9dd82c1 | 2012-07-20 18:50:51 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | |
| 23 | int printf(const char *, ...); |
| 24 | void test2() { |
| 25 | printf("∆: %d", 1L); |
| 26 | // CHECK: warning: format specifies type 'int' but the argument has type 'long' |
| 27 | // Don't crash emitting a fixit after the delta. |
| 28 | // CHECK: printf(" |
| 29 | // CHECK: : %d", 1L); |
| 30 | // Unfortunately, we can't actually check the location of the printed fixit, |
| 31 | // because different systems will render the delta differently (either as a |
| 32 | // character, or as <U+2206>.) The fixit should line up with the %d regardless. |
| 33 | |
Jordan Rose | 7f43ddd | 2013-01-24 20:50:46 +0000 | [diff] [blame^] | 34 | // CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{[[@LINE-9]]:16-[[@LINE-9]]:18}:"%ld" |
Benjamin Kramer | 29f90e8 | 2012-07-12 08:20:49 +0000 | [diff] [blame] | 35 | } |