1 /* Test for -Wtraditional warnings on ISO C function definitions.
2 Note, gcc should omit these warnings in system header files.
3 Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 6/30/2002. */
4 /* { dg-do compile } */
5 /* { dg-options "-Wtraditional" } */
7 /* Test some simple cases. */
10 { /* { dg-warning "traditional C rejects ISO C style" } */
20 { /* { dg-warning "traditional C rejects ISO C style" } */
30 /* Test that we don't ever warn about nested functions. */
33 { /* { dg-warning "traditional C rejects ISO C style" } */
34 void f3a (void) { return; }
35 void f3b () { return; }
36 void f3c (int f
) { return; }
37 void f3d (f
) int f
; { return; }
38 void f3e (const char *f
, ...) { return; }
43 { /* { dg-warning "traditional C rejects ISO C style" } */
44 void f4a (void) { return; }
45 void f4b () { return; }
46 void f4c (int f
) { return; }
47 void f4d (f
) int f
; { return; }
48 void f4e (const char *f
, ...) { return; }
49 auto f4f (void) { return 0; }
56 void f5a (void) { return; }
57 void f5b () { return; }
58 void f5c (int f
) { return; }
59 void f5d (f
) int f
; { return; }
60 void f5e (const char *f
, ...) { return; }
67 void f6a (void) { return; }
68 void f6b () { return; }
69 void f6c (int f
) { return; }
70 void f6d (f
) int f
; { return; }
71 void f6e (const char *f
, ...) { return; }
72 auto f6f (void) { return 0; }
76 /* Test that prototypes are silently accepted and function definitions
77 are still warned about. */
79 extern void f_int_p1 (int);
81 { /* { dg-warning "traditional C rejects ISO C style" } */
85 extern void f_int_p2 (int f
);
87 { /* { dg-warning "traditional C rejects ISO C style" } */
91 extern void f_int_p3 (int);
98 extern void f_int_p4 (int f
);
105 extern void f_void_p1 ();
106 void f_void_p1 (void)
107 { /* { dg-warning "traditional C rejects ISO C style" } */
111 extern void f_void_p2 (void);
112 void f_void_p2 (void)
113 { /* { dg-warning "traditional C rejects ISO C style" } */
117 extern void f_blank_p1 ();
123 extern void f_blank_p2 (void);
129 /* Test some implicit int functions. */
137 { /* { dg-warning "traditional C rejects ISO C style" } */
142 { /* { dg-warning "traditional C rejects ISO C style" } */
146 /* Test stdarg functions. */
148 f_stdarg1(const char *s
, ...)
149 { /* { dg-warning "traditional C rejects ISO C style" } */
153 void f_stdarg2(const char *s
, ...)
154 { /* { dg-warning "traditional C rejects ISO C style" } */
158 extern void f_stdarg3(const char *, ...);
159 void f_stdarg3(const char *s
, ...)
160 { /* { dg-warning "traditional C rejects ISO C style" } */
164 /* Test handling function pointer parameters. */
166 void f_fnptr1 (int f
, int (*fp
)(int));
167 void f_fnptr1 (int f
, int (*fp
)(int))
168 { /* { dg-warning "traditional C rejects ISO C style" } */
172 void f_fnptr2 (int f
, int (*fp
)(int));
173 void f_fnptr2 (f
, fp
)
183 main (int argc
, char **argv
)
184 { /* { dg-warning "traditional C rejects ISO C style" } */
188 # 182 "sys-header.h" 3
189 /* We are in system headers now, no -Wtraditional warnings should issue. */
201 void fsys3 (const char *f
, ...)