]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix testsuite failures on Darwin (aka macOS).
authorZack Weinberg <zackw@panix.com>
Sun, 10 Jul 2022 16:06:11 +0000 (12:06 -0400)
committerZack Weinberg <zackw@panix.com>
Sun, 10 Jul 2022 19:05:31 +0000 (15:05 -0400)
Tests of AC_{CHECK_,}HEADER_STDBOOL were failing on Darwin for two
reasons: an m4 quoting bug in tests/local.at causing Darwin sed to
throw syntax errors, and an excessively precise interpretation of how
C99 and C++11 interact.  The latter is worth mentioning in NEWS.

 * tests/local.at (_AT_DEFINES_CMP_PRUNE): Insert [] before ‘dnl’ in
   two places to keep it separate from the result of the m4_bpatsubsts
   operation that immediately precedes it.
 * lib/autoconf/headers.m4 (AC_CHECK_HEADER_STDBOOL): Allow ‘bool’,
   ‘true’, and ‘false’ not to be macros, after including stdbool.h,
   whenever __cplusplus is defined.
 * NEWS: Document change to AC_{CHECK_,}HEADER_STDBOOL.

NEWS
lib/autoconf/headers.m4
tests/local.at

diff --git a/NEWS b/NEWS
index a84757073c8d8c53ec16001bf966b9ee3c4a93fa..ef0f5f83f3d6b9dd795b3f564a6f886235c0b956 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,19 @@ GNU Autoconf NEWS - User visible changes.
   represent cache file timestamps, thus avoiding some problems where
   automake incorrectly decides not to regenerate stale caches.
 
+*** AC_HEADER_STDBOOL and AC_CHECK_HEADER_STDBOOL are less picky.
+
+  When compiling C++, a ‘stdbool.h’ that exists, but does nothing, is
+  acceptable no matter what version of the C++ standard is in use.
+
+  (ISO C++ 2011 says that ‘stdbool.h’ should exist for compatibility
+  with C, but should *not* define ‘bool’, ‘true’, or ‘false’ as
+  macros.  ISO C++ 1998 doesn’t mention ‘stdbool.h’ at all.  Some C++
+  compilers implement the 2011 rule in their C++98 mode as well.
+  ‘bool’, ‘true’, and ‘false’ have been built into the C++ language
+  since the beginning, so a ‘stdbool.h’ that exists but does nothing
+  should be fine for all reasonable C++ programs.)
+
 * Noteworthy changes in release 2.71 (2021-01-28) [stable]
 
 ** Bug fixes, including:
index 8944da41cfb927a45f219028bd91b8c5cb9c30e8..5cd1f4d55840910aca3d736454bc99dc018dd4d1 100644 (file)
@@ -633,8 +633,10 @@ AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
              bool *pp = &p;
 
              /* C 1999 specifies that bool, true, and false are to be
-                macros, but C++ 2011 and later overrule this.  */
-             #if __cplusplus < 201103
+                macros, but C++ 2011 overrules this.  The C++ committee
+                was codifying existing practice, so we allow them to
+                not be macros whenever __cplusplus is defined.  */
+             #ifndef __cplusplus
               #ifndef bool
                #error "bool is not defined"
               #endif
index 3f348929f392f0ab6210eef28464568d7d1f86d3..f79f57ff1569291ed2ab755b59a49718df264631 100644 (file)
@@ -593,9 +593,9 @@ AT_CMP([at_defines-$1], [at_defines-$2])[]dnl
 m4_define([_AT_DEFINES_CMP_PRUNE],
 [m4_bmatch([$1],
   [^vary:],
-[      /@%:@define ]m4_bpatsubsts([$1], [\<vary:], [])dnl
+[      /@%:@define ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
 [@<:@ @{:@@:>@/ d ;@%:@@:}@
-       /@%:@undef ]m4_bpatsubsts([$1], [\<vary:], [])dnl
+       /@%:@undef ]m4_bpatsubsts([$1], [\<vary:], [])[]dnl
 [@<:@ @{:@@:>@/ d ;@%:@@:}@
 ],
   [m4_fatal([unrecognized AT_DEFINES_CMP variance token: "$1"])])])