>From ef0cd33aa5bc626a4a0063062aaae5fd80bf185f Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Tue, 1 Jun 2010 21:54:39 +0200 Subject: [PATCH 2/2] Documentation and tests for the AC_CHECK_DECL change. * lib/autoconf/general.m4 (_AC_CHECK_DECL_BODY): Squash trailing spaces in as_decl_name. (_AC_CHECK_DECLS): Likewise for the define. * tests/semantics.at (AC_CHECK_DECLS): Extend test. * doc/autoconf.texi (Generic Declarations): Update. * NEWS: Update. Signed-off-by: Ralf Wildenhues --- ChangeLog | 10 ++++++++++ NEWS | 3 +++ doc/autoconf.texi | 14 +++++++++++--- lib/autoconf/general.m4 | 4 ++-- tests/semantics.at | 35 +++++++++++++++++++++++++++++++++-- 5 files changed, 59 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8041556..08bcde8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-06-01 Ralf Wildenhues + + Documentation and tests for the AC_CHECK_DECL change. + * lib/autoconf/general.m4 (_AC_CHECK_DECL_BODY): Squash trailing + spaces in as_decl_name. + (_AC_CHECK_DECLS): Likewise for the define. + * tests/semantics.at (AC_CHECK_DECLS): Extend test. + * doc/autoconf.texi (Generic Declarations): Update. + * NEWS: Update. + 2010-06-01 Joern Rennecke (tiny change) Generalize AC_CHECK_DECL for C++: allow optional arguments. diff --git a/NEWS b/NEWS index afd8907..04cf8dd 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,9 @@ GNU Autoconf NEWS - User visible changes. ** Autoconf should work on EBCDIC hosts. +** AC_CHECK_DECL and AC_CHECK_DECLS accept optional function argument types + for overloaded C++ functions. + * Major changes in Autoconf 2.65 (2009-11-21) [stable] Released by Eric Blake, based on git versions 2.64.*. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 3df0d3f..eab9ab2 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -6275,8 +6275,14 @@ Generic Declarations This macro actually tests whether @var{symbol} is defined as a macro or can be used as an r-value, not whether it is really declared, because it -is much safer to avoid -introducing extra declarations when they are not needed. +is much safer to avoid introducing extra declarations when they are not +needed. In order to facilitate use of C++ and overloaded function +declarations, it is possible to specify function argument types in +parentheses for types which can be zero-initialized: + address@hidden +AC_CHECK_DECL([basename(char *)]) address@hidden example This macro caches its result in the @address@hidden variable, with characters not suitable for a variable name mapped to @@ -6289,7 +6295,8 @@ Generic Declarations @acindex{CHECK_DECLS} @cvindex address@hidden @caindex address@hidden -For each of the @var{symbols} (@emph{comma}-separated list), define +For each of the @var{symbols} (@emph{comma}-separated list with optional +function argument types for C++ overloads), define @address@hidden (in all capitals) to @samp{1} if @var{symbol} is declared, otherwise to @samp{0}. If @var{action-if-not-found} is given, it is additional shell code to @@ -6306,6 +6313,7 @@ Generic Declarations AC_CHECK_DECLS([strlen]) AC_CHECK_DECLS([malloc, realloc, calloc, free]) AC_CHECK_DECLS([j0], [], [], [[#include ]]) +AC_CHECK_DECLS([[basename(char *)], [dirname(char *)]]) @end example Unlike the other @samp{AC_CHECK_*S} macros, when a @var{symbol} is not diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index fecfb72..762a56c 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2792,7 +2792,7 @@ AC_DEFUN([AC_CHECK_FILES], # Shell function body for AC_CHECK_DECL. m4_define([_AC_CHECK_DECL_BODY], [ AS_LINENO_PUSH([$[]1]) - [as_decl_name=`echo $][2|sed 's/(.*//'`] + [as_decl_name=`echo $][2|sed 's/ *(.*//'`] [as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`] AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4], @@ -2837,7 +2837,7 @@ AS_VAR_POPDEF([ac_Symbol])dnl # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND. m4_define([_AC_CHECK_DECLS], [AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl -[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[(.*])), +[AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])), [$ac_have_decl], [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])]dnl diff --git a/tests/semantics.at b/tests/semantics.at index bb4481b..b703fd4 100644 --- a/tests/semantics.at +++ b/tests/semantics.at @@ -109,9 +109,40 @@ AT_CHECK_MACRO([AC_CHECK_DECLS], struct { int x[20]; } mystruct; extern int myfunc(); #define mymacro1(arg) arg - #define mymacro2]])]], + #define mymacro2]]) + # The difference in space-before-open-paren is intentional. + AC_CHECK_DECLS([basenam (char *), dirnam(char *), + [moreargs (char, short, int, long, void *, char [], float, double)]],,, + [[#ifdef __cplusplus + extern "C++" char *basenam (char *); + extern "C++" const char *basenam (const char *); + #else + extern char *basenam (const char *); + #endif + #ifdef __cplusplus + extern "C" { + #endif + extern int moreargs (char, short, int, long, void *, + char [], float, double); + #ifdef __cplusplus + } + #endif + ]]) + AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])], + [[#ifdef __cplusplus + extern "C++" char *declared (char *); + extern "C++" const char *declared (const char *); + #else + extern char *declared (const char *); + #endif + ]]) + AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]]) +]], [AT_CHECK_DEFINES( -[#define HAVE_DECL_MYENUM 1 +[#define HAVE_DECL_BASENAM 1 +#define HAVE_DECL_DIRNAM 0 +#define HAVE_DECL_MOREARGS 1 +#define HAVE_DECL_MYENUM 1 #define HAVE_DECL_MYFUNC 1 #define HAVE_DECL_MYMACRO1 1 #define HAVE_DECL_MYMACRO2 1 -- 1.7.0.rc1.161.g90487