From f13c9c83fe8670dc5e9e620dc521d8f7df45248d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 13 May 2020 16:34:17 +0200 Subject: [PATCH] configure: add test for C++17 feature "constexpr if" --- ac/c++-features.m4 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ac/c++-features.m4 b/ac/c++-features.m4 index bdaf3fb66..c46c6b576 100644 --- a/ac/c++-features.m4 +++ b/ac/c++-features.m4 @@ -506,6 +506,29 @@ AC_DEFUN([AX_CXX17_STD_GCD],[ fi ]) +AC_DEFUN([AX_CXX17_CONSTEXPR_IF],[ + AC_CACHE_CHECK([for support for C++17 feature "constexpr if"], [ax_cv_cxx17_constexpr_if],[ + + CXXFLAGS_SAVED=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $STD_CXX" + export CXXFLAGS + + AC_LANG_PUSH(C++) + AC_TRY_COMPILE( + [], + [if constexpr (true) return 42; else return 54;], + [ax_cv_cxx17_constexpr_if="yes"], + [ax_cv_cxx17_constexpr_if="no"]) + AC_LANG_POP + + CXXFLAGS="$CXXFLAGS_SAVED" + ]) + + if ! test x"$ax_cv_cxx17_constexpr_if" = xyes ; then + missing_cxx_features="$missing_cxx_features\n * constexpr if (C++17)" + fi +]) + dnl AC_DEFUN([AX_CXX17_DEF_NAME],[ dnl AC_CACHE_CHECK([for support for C++17 feature "human"], [ax_cv_cxx17_def_name],[ dnl @@ -548,6 +571,7 @@ AX_CXX17_NESTED_NAMESPACE_DEFINITION AX_CXX17_STRUCTURED_BINDINGS AX_CXX17_STD_OPTIONAL AX_CXX17_STD_GCD +AX_CXX17_CONSTEXPR_IF if test x"$missing_cxx_features" != x ; then printf "The following features of the C++11/C++14/C++17 standards are not supported by $CXX:$missing_cxx_features\n"