* testsuite/libgomp.fortran/vla7.f90: Add -w to options.
[official-gcc.git] / gcc / testsuite / gcc.dg / wtr-func-def-1.c
blob32d613ea748b06ca9ad1edc3c8a4d83ca85a1fcb
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. */
9 void f_void1 (void)
10 { /* { dg-warning "traditional C rejects ISO C style" } */
11 return;
14 void f_void2 ()
16 return;
19 void f_int1 (int f)
20 { /* { dg-warning "traditional C rejects ISO C style" } */
21 return;
24 void f_int2 (f)
25 int f;
27 return;
30 /* Test that we don't ever warn about nested functions. */
32 void f_int3 (int f)
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; }
39 return;
42 void f_int4 (int f)
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; }
50 return;
53 void f_int5 (f)
54 int f;
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; }
61 return;
64 void f_int6 (f)
65 int f;
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; }
73 return;
76 /* Test that prototypes are silently accepted and function definitions
77 are still warned about. */
79 extern void f_int_p1 (int);
80 void f_int_p1 (int f)
81 { /* { dg-warning "traditional C rejects ISO C style" } */
82 return;
85 extern void f_int_p2 (int f);
86 void f_int_p2 (int f)
87 { /* { dg-warning "traditional C rejects ISO C style" } */
88 return;
91 extern void f_int_p3 (int);
92 void f_int_p3 (f)
93 int f;
95 return;
98 extern void f_int_p4 (int f);
99 void f_int_p4 (f)
100 int f;
102 return;
105 extern void f_void_p1 ();
106 void f_void_p1 (void)
107 { /* { dg-warning "traditional C rejects ISO C style" } */
108 return;
111 extern void f_void_p2 (void);
112 void f_void_p2 (void)
113 { /* { dg-warning "traditional C rejects ISO C style" } */
114 return;
117 extern void f_blank_p1 ();
118 void f_blank_p1 ()
120 return;
123 extern void f_blank_p2 (void);
124 void f_blank_p2 ()
126 return;
129 /* Test some implicit int functions. */
131 f_impl1()
133 return 0;
136 f_impl2(void)
137 { /* { dg-warning "traditional C rejects ISO C style" } */
138 return 0;
141 f_impl3(int f)
142 { /* { dg-warning "traditional C rejects ISO C style" } */
143 return 0;
146 /* Test stdarg functions. */
148 f_stdarg1(const char *s, ...)
149 { /* { dg-warning "traditional C rejects ISO C style" } */
150 return 0;
153 void f_stdarg2(const char *s, ...)
154 { /* { dg-warning "traditional C rejects ISO C style" } */
155 return;
158 extern void f_stdarg3(const char *, ...);
159 void f_stdarg3(const char *s, ...)
160 { /* { dg-warning "traditional C rejects ISO C style" } */
161 return;
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" } */
169 return;
172 void f_fnptr2 (int f, int (*fp)(int));
173 void f_fnptr2 (f, fp)
174 int f;
175 int (*fp)(int);
177 return;
180 /* Test for main. */
183 main (int argc, char **argv)
184 { /* { dg-warning "traditional C rejects ISO C style" } */
185 return 0;
188 # 182 "sys-header.h" 3
189 /* We are in system headers now, no -Wtraditional warnings should issue. */
191 void fsys1 (void)
193 return;
196 void fsys2 (int f)
198 return;
201 void fsys3 (const char *f, ...)
203 return;