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