Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 3 | // RUN: cp %s %t |
Douglas Gregor | 27766d2 | 2011-04-27 03:47:06 +0000 | [diff] [blame] | 4 | // RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 5 | // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 6 | |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 7 | struct Point { |
| 8 | float x, y; |
| 9 | }; |
| 10 | |
| 11 | struct Rectangle { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 12 | struct Point top_left, // expected-note{{'top_left' declared here}} |
| 13 | bottom_right; |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 14 | }; |
| 15 | |
| 16 | enum Color { Red, Green, Blue }; |
| 17 | |
| 18 | struct Window { |
Douglas Gregor | 67dd1d4 | 2010-01-07 00:17:44 +0000 | [diff] [blame] | 19 | struct Rectangle bounds; // expected-note{{'bounds' declared here}} |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 20 | enum Color color; |
| 21 | }; |
| 22 | |
| 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'?}} |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 25 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:9}:"bounds" |
| 26 | |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 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'?}} |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 28 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"top_left" |
Douglas Gregor | c171e3b | 2010-01-01 00:03:05 +0000 | [diff] [blame] | 29 | 2.71818, 5.0, 6.0, Red |
| 30 | }; |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 31 | |
| 32 | void test() { |
| 33 | Rectangle r1; // expected-error{{must use 'struct' tag to refer to type 'Rectangle'}} |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 34 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:3}:"struct " |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 35 | r1.top_left.x = 0; |
| 36 | |
| 37 | typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}} |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 38 | rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}} |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 39 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"Rectangle" |
| 40 | |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 41 | r2->top_left.y = 0; |
| 42 | unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}} |
Dmitri Gribenko | ff3e102 | 2013-01-25 21:41:29 +0000 | [diff] [blame] | 43 | // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"unsigned" |
Douglas Gregor | 312eadb | 2011-04-24 05:37:28 +0000 | [diff] [blame] | 44 | *ptr = 17; |
| 45 | } |