Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 2 | // RUN: cp %s %t |
Douglas Gregor | 27766d2 | 2011-04-27 03:47:06 +0000 | [diff] [blame] | 3 | // RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 5 | // RUN: grep "Rectangle" %t |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 6 | struct Point { |
| 7 | float x, y; |
| 8 | }; |
| 9 | |
| 10 | struct Rectangle { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 11 | struct Point top_left, // expected-note{{'top_left' declared here}} |
| 12 | bottom_right; |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | enum Color { Red, Green, Blue }; |
| 16 | |
| 17 | struct Window { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 18 | struct Rectangle bounds; // expected-note{{'bounds' declared here}} |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 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 | }; |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 27 | |
| 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}} |
Douglas Gregor | 27766d2 | 2011-04-27 03:47:06 +0000 | [diff] [blame] | 33 | rectangle *r2 = &r1; // expected-error{{ unknown type name 'rectangle'; did you mean 'Rectangle'?}} |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 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 | } |