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