xref: /aosp_15_r20/external/clang/test/FixIt/fixit-errors.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2*67e74705SXin Li // RUN: cp %s %t
3*67e74705SXin Li // RUN: not %clang_cc1 -pedantic -fixit -x c %t
4*67e74705SXin Li // RUN: %clang_cc1 -pedantic -Werror -Wno-invalid-noreturn -x c %t
5*67e74705SXin Li 
6*67e74705SXin Li /* This is a test of the various code modification hints that are
7*67e74705SXin Li    provided as part of warning or extension diagnostics. All of the
8*67e74705SXin Li    warnings will be fixed by -fixit, and the resulting file should
9*67e74705SXin Li    compile cleanly with -Werror -pedantic. */
10*67e74705SXin Li 
11*67e74705SXin Li struct s; // expected-note{{previous use is here}}
12*67e74705SXin Li 
13*67e74705SXin Li union s *s1; // expected-error{{use of 's' with tag type that does not match previous declaration}}
14*67e74705SXin Li 
15*67e74705SXin Li struct Point {
16*67e74705SXin Li   float x, y, z;
17*67e74705SXin Li };
18*67e74705SXin Li 
19*67e74705SXin Li struct Point *get_origin();
20*67e74705SXin Li 
test_point()21*67e74705SXin Li void test_point() {
22*67e74705SXin Li   (void)get_origin->x; // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments?}}
23*67e74705SXin Li }
24*67e74705SXin Li 
25*67e74705SXin Li // These errors require C11.
26*67e74705SXin Li #if __STDC_VERSION__ > 199901L
27*67e74705SXin Li void noreturn_1() _Noreturn; // expected-error {{must precede function declarator}}
noreturn_1()28*67e74705SXin Li void noreturn_1() {
29*67e74705SXin Li   return; // expected-warning {{should not return}}
30*67e74705SXin Li }
noreturn_2()31*67e74705SXin Li void noreturn_2() _Noreturn { // expected-error {{must precede function declarator}}
32*67e74705SXin Li   return; // expected-warning {{should not return}}
33*67e74705SXin Li }
34*67e74705SXin Li #endif
35