Home | History | Annotate | Download | only in FixIt
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 // RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
      3 // RUN: cp %s %t
      4 // RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t
      5 // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t
      6 
      7 struct Point {
      8   float x, y;
      9 };
     10 
     11 struct Rectangle {
     12   struct Point top_left, // expected-note{{'top_left' declared here}}
     13                bottom_right;
     14 };
     15 
     16 enum Color { Red, Green, Blue };
     17 
     18 struct Window {
     19   struct Rectangle bounds; // expected-note{{'bounds' declared here}}
     20   enum Color color;
     21 };
     22 
     23 struct Window window = {
     24   .bunds. // expected-error{{field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'?}}
     25   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:9}:"bounds"
     26 
     27   topleft.x = 3.14, // expected-error{{field designator 'topleft' does not refer to any field in type 'struct Rectangle'; did you mean 'top_left'?}}
     28   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"top_left"
     29   2.71818, 5.0, 6.0, Red
     30 };
     31 
     32 void test() {
     33   Rectangle r1; // expected-error{{must use 'struct' tag to refer to type 'Rectangle'}}
     34   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:3}:"struct "
     35   r1.top_left.x = 0;
     36 
     37   typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}}
     38   rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}}
     39   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"Rectangle"
     40 
     41   r2->top_left.y = 0;
     42   unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
     43   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"unsigned"
     44   *ptr = 17;
     45 }
     46