blob: 8e380c94979ada4daa481642ff60cc5fd48babd2 [file] [log] [blame]
Douglas Gregorc171e3b2010-01-01 00:03:05 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +00002// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00003// RUN: cp %s %t
Douglas Gregor27766d22011-04-27 03:47:06 +00004// RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00005// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +00006
Douglas Gregorc171e3b2010-01-01 00:03:05 +00007struct Point {
8 float x, y;
9};
10
11struct Rectangle {
Douglas Gregor67dd1d42010-01-07 00:17:44 +000012 struct Point top_left, // expected-note{{'top_left' declared here}}
13 bottom_right;
Douglas Gregorc171e3b2010-01-01 00:03:05 +000014};
15
16enum Color { Red, Green, Blue };
17
18struct Window {
Douglas Gregor67dd1d42010-01-07 00:17:44 +000019 struct Rectangle bounds; // expected-note{{'bounds' declared here}}
Douglas Gregorc171e3b2010-01-01 00:03:05 +000020 enum Color color;
21};
22
23struct Window window = {
24 .bunds. // expected-error{{field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'?}}
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +000025 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:9}:"bounds"
26
Douglas Gregorc171e3b2010-01-01 00:03:05 +000027 topleft.x = 3.14, // expected-error{{field designator 'topleft' does not refer to any field in type 'struct Rectangle'; did you mean 'top_left'?}}
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +000028 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"top_left"
Douglas Gregorc171e3b2010-01-01 00:03:05 +000029 2.71818, 5.0, 6.0, Red
30};
Douglas Gregor312eadb2011-04-24 05:37:28 +000031
32void test() {
33 Rectangle r1; // expected-error{{must use 'struct' tag to refer to type 'Rectangle'}}
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +000034 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:3}:"struct "
Douglas Gregor312eadb2011-04-24 05:37:28 +000035 r1.top_left.x = 0;
36
37 typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}}
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000038 rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}}
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +000039 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"Rectangle"
40
Douglas Gregor312eadb2011-04-24 05:37:28 +000041 r2->top_left.y = 0;
42 unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
Dmitri Gribenkoff3e1022013-01-25 21:41:29 +000043 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"unsigned"
Douglas Gregor312eadb2011-04-24 05:37:28 +000044 *ptr = 17;
45}