[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / FixIt / typo.c
blob524e40068638396a71fe7bcda2ccf79bbfbacaa8
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 -fixit -x c %t
5 // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t
7 struct Point {
8 float x, y;
9 };
11 struct Rectangle {
12 struct Point top_left, // expected-note{{'top_left' declared here}}
13 bottom_right;
16 enum Color { Red, Green, Blue };
18 struct Window {
19 struct Rectangle bounds; // expected-note{{'bounds' declared here}}
20 enum Color color;
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"
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
32 void test(void) {
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;
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"
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;