From 39eed22b3e82a7e453ecf9086afc601851d9a399 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 19 Aug 2020 03:18:52 +0200
Subject: [PATCH] uchar C++ tests: Fix side effect on math modules (regr.
 2020-08-17).

* modules/uchar-c++-tests (configure.ac): Don't use AC_LANG_PUSH and
AC_LANG_POP.
---
 ChangeLog               |  6 ++++++
 modules/uchar-c++-tests | 19 ++++++++++---------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9ba0cda927..cbd3803a3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-08-18  Bruno Haible  <bruno@clisp.org>
+
+	uchar C++ tests: Fix side effect on math modules (regr. 2020-08-17).
+	* modules/uchar-c++-tests (configure.ac): Don't use AC_LANG_PUSH and
+	AC_LANG_POP.
+
 2020-08-17  Paul Eggert  <eggert@cs.ucla.edu>
 
 	verify: avoid __built_assume on Clang
diff --git a/modules/uchar-c++-tests b/modules/uchar-c++-tests
index 2cbc3312b5..351bdff7b5 100644
--- a/modules/uchar-c++-tests
+++ b/modules/uchar-c++-tests
@@ -16,15 +16,16 @@ if test "$CXX" != no; then
   dnl have the <cuchar> header file from C++11.
   AC_CACHE_CHECK([whether the C++ compiler has <cuchar>],
     [gl_cv_cxxheader_cuchar],
-    [AC_LANG_PUSH([C++])
-     AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <cuchar>]],
-          [[]])
-       ],
-       [gl_cv_cxxheader_cuchar=yes],
-       [gl_cv_cxxheader_cuchar=no])
-     AC_LANG_POP([C++])
+    [dnl We can't use AC_LANG_PUSH([C++]) and AC_LANG_POP([C++]) here, due to
+     dnl an autoconf bug <https://savannah.gnu.org/support/?110294>.
+     echo '#include <cuchar>' > conftest.cpp
+     gl_command="$CXX $CXXFLAGS $CPPFLAGS -c conftest.cpp"
+     if AC_TRY_EVAL([gl_command]); then
+       gl_cv_cxxheader_cuchar=yes
+     else
+       gl_cv_cxxheader_cuchar=no
+     fi
+     rm -fr conftest*
     ])
 else
   gl_cv_cxxheader_cuchar=no
-- 
2.39.5