autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix AC_CHECK_DECL


From: Paul Eggert
Subject: Re: Fix AC_CHECK_DECL
Date: Tue, 26 Sep 2006 12:58:37 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> I think there could be issues on systems where pointers to data and
> pointers to functions are incompatible,

Yes, that could well be.

Also, the patch mishandles enum identifiers.  They don't have
addresses.

The current code dates back to K&R compilers that did not support
C89.  How about if we just assume C89 or better here, and cast
the expression to void?

I installed this:

2006-09-26  Paul Eggert  <address@hidden>

        * NEWS: AC_CHECK_DECL now also works with aggregate objects.
        * doc/autoconf.texi (Generic Declarations): Clarify that AC_CHECK_DECL
        can apply to constants too, and that it checks for macro defns.
        * lib/autoconf/general.m4 (AC_CHECK_DECL): Assume C89 or better,
        and simply cast the identifier to void.  This handles structure
        values.  Problem reported by Ralf Wildenhues.
        * tests/semantics.at (AC_CHECK_DECLS): Also check enums.

2006-09-26  Ralf Wildenhues  <address@hidden>

        * tests/semantics.at (AC_CHECK_DECLS): Also check macros,
        structure, and function symbols.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.401
diff -u -r1.401 NEWS
--- NEWS        26 Sep 2006 06:04:35 -0000      1.401
+++ NEWS        26 Sep 2006 19:55:43 -0000
@@ -13,6 +13,8 @@
   New macro, with the behavior of the 2.60a AC_COMPUTE_INT macro.
   AC_COMPUTE_INT no longer caches or reports results.

+** AC_CHECK_DECL now also works with aggregate objects.
+
 ** GNU M4 1.4.7 or later is now recommended.

 * Major changes in Autoconf 2.60a (2006-08-25)
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1086
diff -u -r1.1086 autoconf.texi
--- doc/autoconf.texi   26 Sep 2006 06:04:35 -0000      1.1086
+++ doc/autoconf.texi   26 Sep 2006 19:55:44 -0000
@@ -5645,14 +5645,15 @@

 @defmac AC_CHECK_DECL (@var{symbol}, @ovar{action-if-found}, 
@ovar{action-if-not-found}, @dvar{includes, default-includes})
 @acindex{CHECK_DECL}
-If @var{symbol} (a function or a variable) is not declared in
+If @var{symbol} (a function, variable, or constant) is not declared in
 @var{includes} and a declaration is needed, run the shell commands
 @var{action-if-not-found}, otherwise @var{action-if-found}.  If no
 @var{includes} are specified, the default includes are used
 (@pxref{Default Includes}).

-This macro actually tests whether it is valid to use @var{symbol} as an
-r-value, not if it is really declared, because it is much safer to avoid
+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.
 @end defmac

Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.930
diff -u -r1.930 general.m4
--- lib/autoconf/general.m4     14 Sep 2006 09:40:59 -0000      1.930
+++ lib/autoconf/general.m4     26 Sep 2006 19:55:44 -0000
@@ -2540,14 +2540,13 @@
 #               [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #               [INCLUDES = DEFAULT-INCLUDES])
 # -------------------------------------------------------
-# Check if SYMBOL (a variable or a function) is declared.
+# Check whether SYMBOL (a function, variable, or constant) is declared.
 AC_DEFUN([AC_CHECK_DECL],
 [AS_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
 AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
 [#ifndef $1
-  char *p = (char *) $1;
-  return !p;
+  (void) $1;
 #endif
 ])],
                   [AS_VAR_SET(ac_Symbol, yes)],
Index: tests/semantics.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/semantics.at,v
retrieving revision 1.56
diff -u -r1.56 semantics.at
--- tests/semantics.at  17 Mar 2006 20:37:26 -0000      1.56
+++ tests/semantics.at  26 Sep 2006 19:55:45 -0000
@@ -104,12 +104,21 @@
 # AC_CHECK_DECLS
 # --------------
 # Check that it performs the correct actions:
-# Must define NEED_NO_DECL, but not NEED_YES_DECL.
 AT_CHECK_MACRO([AC_CHECK_DECLS],
-[[AC_CHECK_DECLS([yes, no],,,
-                [int yes = 1;])]],
+[[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
+                [[int yes = 1;
+                  enum { myenum };
+                  struct { int x[20]; } mystruct;
+                  extern int myfunc();
+                  #define mymacro1(arg) arg
+                  #define mymacro2]])]],
 [AT_CHECK_DEFINES(
-[#define HAVE_DECL_NO 0
+[#define HAVE_DECL_MYENUM 1
+#define HAVE_DECL_MYFUNC 1
+#define HAVE_DECL_MYMACRO1 1
+#define HAVE_DECL_MYMACRO2 1
+#define HAVE_DECL_MYSTRUCT 1
+#define HAVE_DECL_NO 0
 #define HAVE_DECL_YES 1
 ])])





reply via email to

[Prev in Thread] Current Thread [Next in Thread]