From: Paul Eggert Date: Fri, 13 Apr 2007 07:52:57 +0000 (+0000) Subject: * NEWS: Document recent changes to AC_CHECK_ALIGNOF, AC_CHECK_SIZEOF, X-Git-Tag: v2.62~329 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ccb4472188da41253029abe6b70e293dc17aeac;p=thirdparty%2Fautoconf.git * NEWS: Document recent changes to AC_CHECK_ALIGNOF, AC_CHECK_SIZEOF, AC_CHECK_TYPE, AC_CHECK_TYPES. * doc/autoconf.texi (Generic types): C types must be type-names (the C terminology), not type-ids (the C++ term). C++ types must not be anonymous. * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW): Remove special case for C++; this drops support for anonymous struct and union types, which were problematic anyway. * tests/semantics.at (AC_CHECK_HEADERS_NEW): Adjust test to work even for C++. --- diff --git a/ChangeLog b/ChangeLog index 0e052f64..c40af552 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-04-12 Paul Eggert + + * NEWS: Document recent changes to AC_CHECK_ALIGNOF, AC_CHECK_SIZEOF, + AC_CHECK_TYPE, AC_CHECK_TYPES. + * doc/autoconf.texi (Generic types): C types must be type-names + (the C terminology), not type-ids (the C++ term). C++ types + must not be anonymous. + * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW): Remove special case + for C++; this drops support for anonymous struct and union types, + which were problematic anyway. + * tests/semantics.at (AC_CHECK_HEADERS_NEW): Adjust test to work even + for C++. + 2007-04-12 Jim Meyering * doc/autoconf.texi (Libraries): Typo fix: insert missing "in". diff --git a/NEWS b/NEWS index b9e6487d..a07ee210 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,20 @@ ** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X. +** AC_CHECK_ALIGNOF's type argument T is now documented better: it must + be a string of tokens such that "T y;" is a valid member declaration + in a struct. + +** AC_CHECK_SIZEOF now accepts objects as well as types: the general rule + is that sizeof (X) works, then AC_CHECK_SIZEOF (X) should work. + +** AC_CHECK_TYPE and AC_CHECK_TYPES now work on any C type-name; formerly, + they did not work for function types. In C++, they now work on any + type-id that can be the operand of sizeof; this is similar to C, + except it excludes anonymous struct and union types. Formerly, + some (but not all) C++ types involving anonymous struct and union + were accepted, though this was not documented. + ** Autoconf now requires GNU M4 1.4.5 or later. Earlier versions of M4 have a bug in macro tracing that interferes with the interaction between Autoconf and Automake. GNU M4 1.4.8 or later is recommended. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 49e925fc..5b4771e2 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -6120,13 +6120,11 @@ test macros. Check whether @var{type} is defined. It may be a compiler builtin type or defined by the @var{includes} (@pxref{Default Includes}). -In C, @var{type} must be a type-id, so that the expression @samp{sizeof +In C, @var{type} must be a type-name, so that the expression @samp{sizeof (@var{type})} is valid (but @samp{sizeof ((@var{type}))} is not). The -rules in C++ are currently more complicated and restrictive: @var{type} -must be a string of tokens such that @samp{typedef @var{type} foo;} is a -valid type definition. However, the C++ approach has problems (for -example, it mishandles function types) and may change in future versions -of Autoconf. +same test is applied when compiling for C++, which means that in C++ +@var{type} should be a type-id and should not be an anonymous +@samp{struct} or @samp{union}. @end defmac @@ -6242,7 +6240,7 @@ defines @code{SIZEOF_INT_P} to be 8 on DEC Alpha AXP systems. @defmac AC_CHECK_ALIGNOF (@var{type}, @dvar{includes, default-includes}) @acindex{CHECK_ALIGNOF} Define @code{ALIGNOF_@var{type}} (@pxref{Standard Symbols}) to be the -alignment in bytes of @var{type}. @samp{@var{type} x;} must be valid as +alignment in bytes of @var{type}. @samp{@var{type} y;} must be valid as a structure member declaration. If @samp{type} is unknown, the result is 0. If no @var{includes} are specified, the default includes are used (@pxref{Default Includes}). diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4 index 2fc95ed1..eb3c8ef8 100644 --- a/lib/autoconf/types.m4 +++ b/lib/autoconf/types.m4 @@ -141,33 +141,19 @@ # if (sizeof (TYPE)) # # to `read' sizeof (to avoid warnings), while not depending on its type -# (not necessarily size_t etc.). Equally, instead of defining an unused -# variable, we just use a cast to avoid warnings from the compiler. -# -# Now, the next issue is that C++ disallows defining types inside casts -# and inside `sizeof()', but we would like to allow unnamed structs, for -# use inside AC_CHECK_SIZEOF, for example. So for C++ we create a typedef -# of the new type. Note that this breaks for some types, e.g., function -# types, but we don't know C++ well enough to fix this. +# (not necessarily size_t etc.). +# +# C++ disallows defining types inside `sizeof ()', but that's OK, +# since we don't want to consider unnamed structs to be types for C++, +# precisely because they don't work in cases like that. m4_define([_AC_CHECK_TYPE_NEW], [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl AC_CACHE_CHECK([for $1], [ac_Type], [AS_VAR_SET([ac_Type], [no]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4]) -#ifdef __cplusplus -typedef $1 ac__type_new_; -#endif -], -[#ifdef __cplusplus -if ((ac__type_new_ *) 0) - return 0; -if (sizeof (ac__type_new_)) - return 0; -#else -if (sizeof ($1)) - return 0; -#endif -])], +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], + [if (sizeof ($1)) + return 0;])], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], [if (sizeof (($1))) diff --git a/tests/semantics.at b/tests/semantics.at index 0a7afdd9..2fa7cde4 100644 --- a/tests/semantics.at +++ b/tests/semantics.at @@ -302,13 +302,13 @@ AC_CHECK_SIZEOF(charcharchar) # ---------------------- AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct], [[AC_C_CONST -AC_CHECK_SIZEOF([struct { char c; int x; }]) -AC_CHECK_SIZEOF([const struct { const char *p; int x; }]) +AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };]) +AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };]) AC_CHECK_SIZEOF([struct nosuchstruct]) ]], -[AT_CHECK([[grep "#define SIZEOF_STRUCT___CHAR_C__INT_X___ [^0]" config.h]], +[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [^0]" config.h]], 0, ignore) -AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT___CONST_CHAR_PP__INT_X___ [^0]" config.h]], +AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [^0]" config.h]], 0, ignore) AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]], 0, ignore)