Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame^] | 1 | From 7a3bbca81b803ba116b83c82de378e840cc35f81 Mon Sep 17 00:00:00 2001 |
| 2 | From: Paul Eggert <eggert@cs.ucla.edu> |
| 3 | Date: Thu, 1 Sep 2022 16:19:50 -0500 |
| 4 | Subject: [PATCH] Port to compilers that moan about K&R func decls |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | * lib/autoconf/c.m4 (AC_LANG_CALL, AC_LANG_FUNC_LINK_TRY): |
| 10 | Use '(void)' rather than '()' in function prototypes, as the latter |
| 11 | provokes fatal errors in some compilers nowadays. |
| 12 | * lib/autoconf/functions.m4 (AC_FUNC_STRTOD): |
| 13 | * tests/fortran.at (AC_F77_DUMMY_MAIN usage): |
| 14 | * tests/semantics.at (AC_CHECK_DECLS): |
| 15 | Don’t use () in a function decl. |
| 16 | |
| 17 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=8b5e2016c7ed2d67f31b03a3d2e361858ff5299b] |
| 18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 19 | --- |
| 20 | doc/autoconf.texi | 7 +++---- |
| 21 | lib/autoconf/c.m4 | 6 +++--- |
| 22 | lib/autoconf/functions.m4 | 3 --- |
| 23 | tests/fortran.at | 8 ++++---- |
| 24 | tests/semantics.at | 2 +- |
| 25 | 5 files changed, 11 insertions(+), 15 deletions(-) |
| 26 | |
| 27 | --- a/doc/autoconf.texi |
| 28 | +++ b/doc/autoconf.texi |
| 29 | @@ -5465,9 +5465,7 @@ the @samp{#undef malloc}): |
| 30 | #include <config.h> |
| 31 | #undef malloc |
| 32 | |
| 33 | -#include <sys/types.h> |
| 34 | - |
| 35 | -void *malloc (); |
| 36 | +#include <stdlib.h> |
| 37 | |
| 38 | /* Allocate an N-byte block of memory from the heap. |
| 39 | If N is zero, allocate a 1-byte block. */ |
| 40 | @@ -8295,7 +8293,7 @@ needed: |
| 41 | # ifdef __cplusplus |
| 42 | extern "C" |
| 43 | # endif |
| 44 | - int F77_DUMMY_MAIN () @{ return 1; @} |
| 45 | + int F77_DUMMY_MAIN (void) @{ return 1; @} |
| 46 | #endif |
| 47 | @end example |
| 48 | |
| 49 | --- a/lib/autoconf/c.m4 |
| 50 | +++ b/lib/autoconf/c.m4 |
| 51 | @@ -127,7 +127,7 @@ m4_if([$2], [main], , |
| 52 | [/* Override any GCC internal prototype to avoid an error. |
| 53 | Use char because int might match the return type of a GCC |
| 54 | builtin and then its argument prototype would still apply. */ |
| 55 | -char $2 ();])], [return $2 ();])]) |
| 56 | +char $2 (void);])], [return $2 ();])]) |
| 57 | |
| 58 | |
| 59 | # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION) |
| 60 | @@ -151,7 +151,7 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)], |
| 61 | #define $1 innocuous_$1 |
| 62 | |
| 63 | /* System header to define __stub macros and hopefully few prototypes, |
| 64 | - which can conflict with char $1 (); below. */ |
| 65 | + which can conflict with char $1 (void); below. */ |
| 66 | |
| 67 | #include <limits.h> |
| 68 | #undef $1 |
| 69 | @@ -162,7 +162,7 @@ m4_define([AC_LANG_FUNC_LINK_TRY(C)], |
| 70 | #ifdef __cplusplus |
| 71 | extern "C" |
| 72 | #endif |
| 73 | -char $1 (); |
| 74 | +char $1 (void); |
| 75 | /* The GNU C library defines this for functions which it implements |
| 76 | to always fail with ENOSYS. Some functions are actually named |
| 77 | something starting with __ and the normal name is an alias. */ |
| 78 | --- a/lib/autoconf/functions.m4 |
| 79 | +++ b/lib/autoconf/functions.m4 |
| 80 | @@ -1601,9 +1601,6 @@ AC_DEFUN([AC_FUNC_STRTOD], |
| 81 | AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod, |
| 82 | [AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 83 | ]AC_INCLUDES_DEFAULT[ |
| 84 | -#ifndef strtod |
| 85 | -double strtod (); |
| 86 | -#endif |
| 87 | int |
| 88 | main (void) |
| 89 | { |
| 90 | --- a/tests/fortran.at |
| 91 | +++ b/tests/fortran.at |
| 92 | @@ -233,7 +233,7 @@ void FOOBAR_F77 (double *x, double *y); |
| 93 | # ifdef __cplusplus |
| 94 | extern "C" |
| 95 | # endif |
| 96 | - int F77_DUMMY_MAIN () { return 1; } |
| 97 | + int F77_DUMMY_MAIN (void) { return 1; } |
| 98 | #endif |
| 99 | |
| 100 | int main(int argc, char *argv[]) |
| 101 | @@ -315,7 +315,7 @@ void FOOBAR_FC(double *x, double *y); |
| 102 | # ifdef __cplusplus |
| 103 | extern "C" |
| 104 | # endif |
| 105 | - int FC_DUMMY_MAIN () { return 1; } |
| 106 | + int FC_DUMMY_MAIN (void) { return 1; } |
| 107 | #endif |
| 108 | |
| 109 | int main (int argc, char *argv[]) |
| 110 | @@ -561,7 +561,7 @@ void @foobar@ (int *x); |
| 111 | # ifdef __cplusplus |
| 112 | extern "C" |
| 113 | # endif |
| 114 | - int F77_DUMMY_MAIN () { return 1; } |
| 115 | + int F77_DUMMY_MAIN (void) { return 1; } |
| 116 | #endif |
| 117 | |
| 118 | int main(int argc, char *argv[]) |
| 119 | @@ -637,7 +637,7 @@ void @foobar@ (int *x); |
| 120 | # ifdef __cplusplus |
| 121 | extern "C" |
| 122 | # endif |
| 123 | - int FC_DUMMY_MAIN () { return 1; } |
| 124 | + int FC_DUMMY_MAIN (void) { return 1; } |
| 125 | #endif |
| 126 | |
| 127 | int main(int argc, char *argv[]) |
| 128 | --- a/tests/semantics.at |
| 129 | +++ b/tests/semantics.at |
| 130 | @@ -207,7 +207,7 @@ AT_CHECK_MACRO([AC_CHECK_DECLS], |
| 131 | [[extern int yes; |
| 132 | enum { myenum }; |
| 133 | extern struct mystruct_s { int x[20]; } mystruct; |
| 134 | - extern int myfunc(); |
| 135 | + extern int myfunc (int); |
| 136 | #define mymacro1(arg) arg |
| 137 | #define mymacro2]]) |
| 138 | # Ensure we can detect missing declarations of functions whose |