summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/wtr-func-def-1.c
blob: 049e05b8551adb629195259290d38062fb5e8c42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/* Test for -Wtraditional warnings on ISO C function definitions.
   Note, gcc should omit these warnings in system header files.
   Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 6/30/2002.  */
/* { dg-do compile } */
/* { dg-options "-Wtraditional" } */

/* Test some simple cases.  */

void f_void1 (void) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

void f_void2 ()
{
  return;
}

void f_int1 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

void f_int2 (f)
     int f;
{
  return;
}

/* Test that we don't ever warn about nested functions.  */

void f_int3 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{
  void f3a (void) { return; }
  void f3b () { return; }
  void f3c (int f) { return; }
  void f3d (f) int f; { return; }
  void f3e (const char *f, ...) { return; }
  return;
}

void f_int4 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{
  void f4a (void) { return; }
  void f4b () { return; }
  void f4c (int f) { return; }
  void f4d (f) int f; { return; }
  void f4e (const char *f, ...) { return; }
  auto f4f (void) { return 0; }
  return;
}

void f_int5 (f)
     int f;
{
  void f5a (void) { return; }
  void f5b () { return; }
  void f5c (int f) { return; }
  void f5d (f) int f; { return; }
  void f5e (const char *f, ...) { return; }
  return;
}

void f_int6 (f)
     int f;
{
  void f6a (void) { return; }
  void f6b () { return; }
  void f6c (int f) { return; }
  void f6d (f) int f; { return; }
  void f6e (const char *f, ...) { return; }
  auto f6f (void) { return 0; }
  return;
}

/* Test that prototypes are silently accepted and function definitions
   are still warned about.  */

extern void f_int_p1 (int);
void f_int_p1 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

extern void f_int_p2 (int f);
void f_int_p2 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

extern void f_int_p3 (int);
void f_int_p3 (f)
     int f;
{
  return;
}

extern void f_int_p4 (int f);
void f_int_p4 (f)
     int f;
{
  return;
}

extern void f_void_p1 ();
void f_void_p1 (void) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

extern void f_void_p2 (void);
void f_void_p2 (void) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

extern void f_blank_p1 ();
void f_blank_p1 ()
{
  return;
}

extern void f_blank_p2 (void);
void f_blank_p2 ()
{
  return;
}

/* Test some implicit int functions.  */

f_impl1()
{
  return 0;
}

f_impl2(void) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return 0;
}

f_impl3(int f) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return 0;
}

/* Test stdarg functions.  */

f_stdarg1(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return 0;
}

void f_stdarg2(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

extern void f_stdarg3(const char *, ...);
void f_stdarg3(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

/* Test handling function pointer parameters.  */

void f_fnptr1 (int f, int (*fp)(int));
void f_fnptr1 (int f, int (*fp)(int)) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return;
}

void f_fnptr2 (int f, int (*fp)(int));
void f_fnptr2 (f, fp)
     int f;
     int (*fp)(int);
{
  return;
}

/* Test for main.  */

int
main (int argc, char **argv) /* { dg-warning "traditional C rejects ISO C style" } */
{
  return 0;
}

# 182 "sys-header.h" 3
/* We are in system headers now, no -Wtraditional warnings should issue.  */

void fsys1 (void)
{
  return;
}

void fsys2 (int f)
{
  return;
}

void fsys3 (const char *f, ...)
{
  return;
}