]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW): Use a typedef to
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 11 Mar 2006 13:22:42 +0000 (13:22 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 11 Mar 2006 13:22:42 +0000 (13:22 +0000)
allow to pass unnamed structs even in C++.
(AC_CHECK_SIZEOF):  Likewise.
Also fix quoting error in `AC_MSG_FAILURE' arguments.
* tests/semantics.at (AC_CHECK_ALIGNOF struct, AC_CHECK_SIZEOF
struct): New tests for unnamed structs, each both native and
cross-compiling.

ChangeLog
lib/autoconf/types.m4
tests/semantics.at

index 0e1798925262adffaf6354fb33ad718426c97c01..264b634098ca194fb7572238eeea7e438bd55db4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2006-03-11  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       * lib/autoconf/types.m4 (_AC_CHECK_TYPE_NEW): Use a typedef to
+       allow to pass unnamed structs even in C++.
+       (AC_CHECK_SIZEOF):  Likewise.
+       Also fix quoting error in `AC_MSG_FAILURE' arguments.
+       * tests/semantics.at (AC_CHECK_ALIGNOF struct, AC_CHECK_SIZEOF
+       struct): New tests for unnamed structs, each both native and
+       cross-compiling.
+
        * lib/autoconf/c.m4 (AC_C_TYPEOF): Use typedef to avoid defining
        a structure inside a cast, for C++ conformance.
        * lib/autoconf/types.m4 (AC_CHECK_ALIGNOF): Likewise.
index fd01247852442009aaf24c1213232f8c7a2d0019..64a57ef0ef3d11e34e6a8e6317e6ceb7b0e3393c 100644 (file)
 # (not necessarily size_t etc.).  Equally, instead of defining an unused
 # variable, we just use a cast to avoid warnings from the compiler.
 # Suggested by Paul Eggert.
+# 
+# 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 we create a typedef of the
+# new type.  Note that this does not obviate the need for the other
+# constructs in general.
 m4_define([_AC_CHECK_TYPE_NEW],
 [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Type,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
-[if (($1 *) 0)
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
+typedef $1 ac__type_new_;],
+[if ((ac__type_new_ *) 0)
   return 0;
-if (sizeof ($1))
+if (sizeof (ac__type_new_))
   return 0;])],
                   [AS_VAR_SET(ac_Type, yes)],
                   [AS_VAR_SET(ac_Type, no)])])
@@ -386,10 +393,11 @@ AC_CACHE_CHECK([size of $1], AS_TR_SH([ac_cv_sizeof_$1]),
   # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
   # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
   # This bug is HP SR number 8606223364.
-  _AC_COMPUTE_INT([(long int) (sizeof ($1))],
+  _AC_COMPUTE_INT([(long int) (sizeof (ac__type_sizeof_))],
                  [AS_TR_SH([ac_cv_sizeof_$1])],
-                 [AC_INCLUDES_DEFAULT([$3])],
-                 [AC_MSG_FAILURE([cannot compute sizeof ($1), 77])])
+                 [AC_INCLUDES_DEFAULT([$3])
+                  typedef $1 ac__type_sizeof_;],
+                 [AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)])
 else
   AS_TR_SH([ac_cv_sizeof_$1])=0
 fi])dnl
index 63885ece92bcc11e6a92a44ceb7aed2eea17eafe..59e337f956179e851669efc3675ded88e10c3b66 100644 (file)
@@ -279,6 +279,35 @@ AC_CHECK_ALIGNOF(charcharchar)
 ])])
 
 
+# AC_CHECK_ALIGNOF struct
+# -----------------------
+# Not cross-compiling.
+AT_CHECK_MACRO([AC_CHECK_ALIGNOF struct],
+[[AC_CHECK_ALIGNOF([struct { char c; }])
+AC_CHECK_ALIGNOF([struct nosuchstruct])
+]],
+[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [^0]" config.h]],
+        0, ignore)
+AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
+        0, ignore)
+])
+
+
+# AC_CHECK_ALIGNOF struct
+# -----------------------
+AT_CHECK_MACRO([AC_CHECK_ALIGNOF struct],
+[[# Exercise the code used when cross-compiling
+cross_compiling=yes
+AC_CHECK_ALIGNOF([struct { char c; }])
+AC_CHECK_ALIGNOF([struct nosuchstruct])
+]],
+[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [^0]" config.h]],
+        0, ignore)
+AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
+        0, ignore)
+])
+
+
 # AC_CHECK_SIZEOF
 # ---------------
 # Not cross-compiling.
@@ -314,6 +343,43 @@ AC_CHECK_SIZEOF(charcharchar)
 ])])
 
 
+# AC_CHECK_SIZEOF structs
+# -----------------------
+# Not cross-compiling.
+AT_CHECK_MACRO([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 nosuchstruct])
+]],
+[AT_CHECK([[grep "#define SIZEOF_STRUCT___CHAR_C__INT_X___ [^0]" config.h]],
+        0, ignore)
+AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT___CONST_CHAR_PP__INT_X___ [^0]" config.h]],
+        0, ignore)
+AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
+        0, ignore)
+])
+
+
+# AC_CHECK_SIZEOF
+# ---------------
+AT_CHECK_MACRO([AC_CHECK_SIZEOF struct],
+[[# Exercise the code used when cross-compiling
+cross_compiling=yes
+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 nosuchstruct])
+]],
+[AT_CHECK([[grep "#define SIZEOF_STRUCT___CHAR_C__INT_X___ [^0]" config.h]],
+        0, ignore)
+AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT___CONST_CHAR_PP__INT_X___ [^0]" config.h]],
+        0, ignore)
+AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
+        0, ignore)
+])
+
+
 # AC_CHECK_TYPES
 # --------------
 # Check that it performs the correct actions.