blob: 0bafd1b9903e56c59f79b6b65516f1717cde51f2 [file] [log] [blame]
Douglas Gregorc171e3b2010-01-01 00:03:05 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00002// RUN: cp %s %t
Douglas Gregor27766d22011-04-27 03:47:06 +00003// RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00004// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t
Douglas Gregor312eadb2011-04-24 05:37:28 +00005// RUN: grep "Rectangle" %t
Douglas Gregorc171e3b2010-01-01 00:03:05 +00006struct Point {
7 float x, y;
8};
9
10struct Rectangle {
Douglas Gregor67dd1d42010-01-07 00:17:44 +000011 struct Point top_left, // expected-note{{'top_left' declared here}}
12 bottom_right;
Douglas Gregorc171e3b2010-01-01 00:03:05 +000013};
14
15enum Color { Red, Green, Blue };
16
17struct Window {
Douglas Gregor67dd1d42010-01-07 00:17:44 +000018 struct Rectangle bounds; // expected-note{{'bounds' declared here}}
Douglas Gregorc171e3b2010-01-01 00:03:05 +000019 enum Color color;
20};
21
22struct 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};
Douglas Gregor312eadb2011-04-24 05:37:28 +000027
28void 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}}
Richard Trieu2fe9b7f2011-12-15 00:38:15 +000033 rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}}
Douglas Gregor312eadb2011-04-24 05:37:28 +000034 r2->top_left.y = 0;
35 unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
36 *ptr = 17;
37}