1c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor// RUN: %clang_cc1 -fsyntax-only -verify %s 296e7813f08c6adf1d8657b0da86741b54e850fd7Rafael Espindola// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s 3ba5f6eced29937e4e4851a2c0980744768413d66Nick Lewycky// RUN: cp %s %t 427766d2501259c7b12b1056e0c491a927b304e10Douglas Gregor// RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t 5ba5f6eced29937e4e4851a2c0980744768413d66Nick Lewycky// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t 6ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko 7c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregorstruct Point { 8c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor float x, y; 9c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor}; 10c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor 11c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregorstruct Rectangle { 1267dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor struct Point top_left, // expected-note{{'top_left' declared here}} 1367dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor bottom_right; 14c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor}; 15c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor 16c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregorenum Color { Red, Green, Blue }; 17c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor 18c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregorstruct Window { 1967dd1d4df1b28973e12e0981129b2517d2033b66Douglas Gregor struct Rectangle bounds; // expected-note{{'bounds' declared here}} 20c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor enum Color color; 21c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor}; 22c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor 23c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregorstruct Window window = { 24c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor .bunds. // expected-error{{field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'?}} 25ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:9}:"bounds" 26ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko 27c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor topleft.x = 3.14, // expected-error{{field designator 'topleft' does not refer to any field in type 'struct Rectangle'; did you mean 'top_left'?}} 28ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:10}:"top_left" 29c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor 2.71818, 5.0, 6.0, Red 30c171e3b192a372669cf622ff0b6a847f8e5b4220Douglas Gregor}; 31312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor 32312eadb832cab4497a069409954500d8192b8f0dDouglas Gregorvoid test() { 33312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor Rectangle r1; // expected-error{{must use 'struct' tag to refer to type 'Rectangle'}} 34ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:3}:"struct " 35312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor r1.top_left.x = 0; 36312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor 37312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}} 382fe9b7fb07dff15dd15dd8755a9a9e6de0fe46fcRichard Trieu rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}} 39ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:12}:"Rectangle" 40ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko 41312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor r2->top_left.y = 0; 42312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}} 43ff3e102bc9dbece2dac365abc9863bc98e49f424Dmitri Gribenko // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:3-[[@LINE-1]]:11}:"unsigned" 44312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor *ptr = 17; 45312eadb832cab4497a069409954500d8192b8f0dDouglas Gregor} 46