summaryrefslogtreecommitdiff
path: root/sys-devel/autoconf/files/autoconf-2.69-K-R-decls-clang.patch
blob: 77444ebc5be6eff41b0a9f7c011710cba8e1234c (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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
https://bugs.gentoo.org/870412
https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=8b5e2016c7ed2d67f31b03a3d2e361858ff5299b
(and contains a backport of https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=bf5a75953b6d504f0405b1ca33b039b8dd39eef4)

Backport the K&R decls fix to 2.69 to avoid configure tests
failing (often "silently", i.e. doesn't fail the build of
the package overall, just leads to wrong results) with
newer compilers like the upcoming Clang 16.

From e6f401b94b58bb9bb58cd668a996e27663d3e6c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me>
Date: Mon, 19 Sep 2022 12:11:24 +0200
Subject: [PATCH] backport K&R decl fixes

--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -97,7 +97,7 @@ m4_define([AC_LANG_PROGRAM(C)],
 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
 m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
 int
-main ()
+main (void)
 {
 dnl Do *not* indent the following line: there may be CPP directives.
 dnl Don't move the `;' right after for the same reason.
@@ -130,7 +130,7 @@ m4_if([$2], [main], ,
 #ifdef __cplusplus
 extern "C"
 #endif
-char $2 ();])], [return $2 ();])])
+char $2 (void);])], [return $2 ();])])
 
 
 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
@@ -154,7 +154,7 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 #define $1 innocuous_$1
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $1 (); below.
+    which can conflict with char $1 (void); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -172,7 +172,7 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)],
 #ifdef __cplusplus
 extern "C"
 #endif
-char $1 ();
+char $1 (void);
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
@@ -201,8 +201,8 @@ return test_array @<:@0@:>@;
 # But we include them only after the EXPRESSION has been evaluated.
 m4_define([AC_LANG_INT_SAVE(C)],
 [AC_LANG_PROGRAM([$1
-static long int longval () { return $2; }
-static unsigned long int ulongval () { return $2; }
+static long int longval (void) { return $2; }
+static unsigned long int ulongval (void) { return $2; }
 @%:@include <stdio.h>
 @%:@include <stdlib.h>],
 [
@@ -1625,8 +1625,8 @@ for ac_kw in inline __inline__ __inline; do
   AC_COMPILE_IFELSE([AC_LANG_SOURCE(
 [#ifndef __cplusplus
 typedef int foo_t;
-static $ac_kw foo_t static_foo () {return 0; }
-$ac_kw foo_t foo () {return 0; }
+static $ac_kw foo_t static_foo (void) {return 0; }
+$ac_kw foo_t foo (void) {return 0; }
 #endif
 ])],
 		    [ac_cv_c_inline=$ac_kw])
@@ -1949,7 +1949,7 @@ m4_define([_AC_LANG_OPENMP(C)],
  choke me
 #endif
 #include <omp.h>
-int main () { return omp_get_num_threads (); }
+int main (void) { return omp_get_num_threads (); }
 ])
 
 # _AC_LANG_OPENMP(C++)
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -463,9 +463,6 @@ AC_CACHE_CHECK([whether closedir returns void],
 	       [ac_cv_func_closedir_void],
 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
 #include <$ac_header_dirent>
-#ifndef __cplusplus
-int closedir ();
-#endif
 ],
 				[[return closedir (opendir (".")) != 0;]])],
 	       [ac_cv_func_closedir_void=no],
@@ -893,7 +890,7 @@ AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
 #else
-char *malloc ();
+char *malloc (long);
 #endif
 ]],
 		 [return ! malloc (0);])],
@@ -1029,7 +1026,7 @@ static const char *tz_strings[] = {
 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
    Based on a problem report from Andreas Jaeger.  */
 static int
-spring_forward_gap ()
+spring_forward_gap (void)
 {
   /* glibc (up to about 1998-10-07) failed this test. */
   struct tm tm;
@@ -1066,7 +1063,7 @@ mktime_test (time_t now)
 }
 
 static int
-irix_6_4_bug ()
+irix_6_4_bug (void)
 {
   /* Based on code from Ariel Faigon.  */
   struct tm tm;
@@ -1108,7 +1105,7 @@ bigtime_test (int j)
 }
 
 static int
-year_2050_test ()
+year_2050_test (void)
 {
   /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
      ignoring leap seconds.  */
@@ -1138,7 +1135,7 @@ year_2050_test ()
 }
 
 int
-main ()
+main (void)
 {
   time_t t, delta;
   int i, j;
@@ -1232,7 +1229,7 @@ AC_CACHE_CHECK([for working mmap], [ac_cv_func_mmap_fixed_mapped],
 #include <sys/mman.h>
 
 #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
-char *malloc ();
+char *malloc (void *, long);
 #endif
 
 /* This mess was copied from the GNU getpagesize.h.  */
@@ -1268,7 +1265,7 @@ char *malloc ();
 #endif /* no HAVE_GETPAGESIZE */
 
 int
-main ()
+main (void)
 {
   char *data, *data2, *data3;
   const char *cdata2;
@@ -1398,7 +1395,7 @@ AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 # include <stdlib.h>
 #else
-char *realloc ();
+char *realloc (void *, long);
 #endif
 ]],
 		 [return ! realloc (0, 0);])],
@@ -1547,11 +1544,8 @@ AC_DEFUN([AC_FUNC_STRTOD],
 AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
 ]AC_INCLUDES_DEFAULT[
-#ifndef strtod
-double strtod ();
-#endif
 int
-main()
+main(void)
 {
   {
     /* Some versions of Linux strtod mis-parse strings with leading '+'.  */
@@ -1645,8 +1639,7 @@ AC_CACHE_CHECK([whether strerror_r returns char *],
       # former has a strerror_r that returns char*, while the latter
       # has a strerror_r that returns `int'.
       # This test should segfault on the DEC system.
-      AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
-	extern char *strerror_r ();],
+      AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
 	[[char buf[100];
 	  char x = *strerror_r (0, buf, sizeof buf);
 	  return ! isalpha (x);]])],
@@ -1879,7 +1872,7 @@ sparc_address_test (arg) int arg;
 }
 
 int
-main ()
+main (void)
 {
   pid_t parent = getpid ();
   pid_t child;
@@ -1985,7 +1978,7 @@ AC_CACHE_CHECK([for wait3 that fills in rusage],
 #include <sys/wait.h>
 /* HP-UX has wait3 but does not fill in rusage at all.  */
 int
-main ()
+main (void)
 {
   struct rusage r;
   int i;
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -712,7 +712,7 @@ if test $ac_cv_header_stdc = yes; then
 
 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
 int
-main ()
+main (void)
 {
   int i;
   for (i = 0; i < 256; i++)
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -257,7 +257,7 @@ void ucatch (dummy) int dummy; { }
 #endif
 
 int
-main ()
+main (void)
 {
   int i = fork (), status;
 
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -267,7 +267,7 @@ AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
 #define MAX(x, y) ((x) > (y) ? (x) : (y))
 
 int
-main ()
+main (void)
 {
   gid_t gidset[NGID];
   int i, n;
--- a/tests/c.at
+++ b/tests/c.at
@@ -354,7 +354,7 @@ AT_DATA([foo.c],
 #endif
 #include <stdio.h>
 
-int main ()
+int main (void)
 {
 #ifdef _OPENMP
 #pragma omp parallel
@@ -404,7 +404,7 @@ foo.@OBJEXT@: foo.cpp
 ]])
 
 AT_DATA([foo.cpp],
-[[int main ()
+[[int main (void)
 {
   return 0;
 }
--- a/tests/compile.at
+++ b/tests/compile.at
@@ -124,7 +124,7 @@ AC_PROG_CC
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PACKAGE_NAME
 choke me
 #endif
-int main ()
+int main (void)
 {
   return 0;
 }
@@ -150,7 +150,7 @@ AC_LANG([C++])
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PACKAGE_NAME
 choke me
 #endif
-int main ()
+int main (void)
 {
   return 0;
 }
@@ -249,7 +249,7 @@ AT_CHECK([sed -n 's/ *$//; /#define PACKAGE/,$p' stdout], [],
 
 const char hw[] = "Hello, World\n";
 int
-main ()
+main (void)
 {
 fputs (hw, stdout);
   ;
@@ -269,7 +269,7 @@ AT_KEYWORDS([AC_LANG_DEFINES_PROVIDED])
 
 AT_DATA([configure.ac],
 [[AC_INIT
-AC_COMPILE_IFELSE([int main () { return 0; }], [],
+AC_COMPILE_IFELSE([int main (void) { return 0; }], [],
   [AC_MSG_ERROR([compiling trivial program failed])])
 ]])
 
@@ -280,7 +280,7 @@ AT_CHECK_CONFIGURE([-q])
 
 AT_DATA([configure.ac],
 [[AC_INIT
-AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED()int main () { return 0; }], [],
+AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED()int main (void) { return 0; }], [],
   [AC_MSG_ERROR([compiling trivial program failed])])
 ]])
 
@@ -324,7 +324,7 @@ test $estatus != 2 &&
   AC_MSG_ERROR([did not get as 2 exit status: $estatus])])
 
 # The old stinky one.
-AC_TRY_RUN([int main () { return 3; }],
+AC_TRY_RUN([int main (void) { return 3; }],
 	   [AC_MSG_ERROR([saw `return 3' as a success])],
 	   [estatus=$?
 test $estatus != 3 &&
--- a/tests/fortran.at
+++ b/tests/fortran.at
@@ -223,7 +223,7 @@ void FOOBAR_F77 (double *x, double *y);
 #  ifdef __cplusplus
      extern "C"
 #  endif
-   int F77_DUMMY_MAIN () { return 1; }
+   int F77_DUMMY_MAIN (void) { return 1; }
 #endif
 
 int main(int argc, char *argv[])
@@ -301,7 +301,7 @@ void FOOBAR_FC(double *x, double *y);
 #  ifdef __cplusplus
      extern "C"
 #  endif
-   int FC_DUMMY_MAIN () { return 1; }
+   int FC_DUMMY_MAIN (void) { return 1; }
 #endif
 
 int main (int argc, char *argv[])
@@ -533,7 +533,7 @@ void @foobar@ (int *x);
 #  ifdef __cplusplus
      extern "C"
 #  endif
-   int F77_DUMMY_MAIN () { return 1; }
+   int F77_DUMMY_MAIN (void) { return 1; }
 #endif
 
 int main(int argc, char *argv[])
@@ -607,7 +607,7 @@ void @foobar@ (int *x);
 #  ifdef __cplusplus
      extern "C"
 #  endif
-   int FC_DUMMY_MAIN () { return 1; }
+   int FC_DUMMY_MAIN (void) { return 1; }
 #endif
 
 int main(int argc, char *argv[])
--- a/tests/semantics.at
+++ b/tests/semantics.at
@@ -107,7 +107,7 @@ AT_CHECK_MACRO([AC_CHECK_DECLS],
 		 [[int yes = 1;
 		   enum { myenum };
 		   struct { int x[20]; } mystruct;
-		   extern int myfunc();
+		   extern int myfunc (void);
 		   #define mymacro1(arg) arg
 		   #define mymacro2]])
   # The difference in space-before-open-paren is intentional.
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1106,9 +1106,7 @@ struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
+static char *e (char **p, int i)
 {
   return p[i];
 }
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -251,10 +251,9 @@ AC_INCLUDES_DEFAULT
 /* Some platforms explicitly require an extern "C" signal handler
    when using C++. */
 #ifdef __cplusplus
-extern "C" void ucatch (int dummy) { }
-#else
-void ucatch (dummy) int dummy; { }
+extern "C"
 #endif
+void ucatch (int dummy) { }
 
 int
 main (void)