Skip to content

Commit 1f4c0b5

Browse files
committed
merge bitcoin#24460: update ax_cxx_compile_stdcxx to serial 14
1 parent c84f5e1 commit 1f4c0b5

File tree

1 file changed

+52
-19
lines changed

1 file changed

+52
-19
lines changed

build-aux/m4/ax_cxx_compile_stdcxx.m4

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
#
1111
# Check for baseline language coverage in the compiler for the specified
1212
# version of the C++ standard. If necessary, add switches to CXX and
13-
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard),
14-
# '14' (for the C++14 standard), '17' (for the C++17 standard) or
15-
# '20' (for the C++20 standard)
13+
# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
14+
# the respective C++ standard version.
1615
#
1716
# The second argument, if specified, indicates whether you insist on an
1817
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
1918
# -std=c++11). If neither is specified, you get whatever works, with
20-
# preference for an extended mode.
19+
# preference for no added switch, and then for an extended mode.
2120
#
2221
# The third argument, if specified 'mandatory' or if left unspecified,
2322
# indicates that baseline support for the specified C++ standard is
@@ -36,25 +35,24 @@
3635
# Copyright (c) 2015 Moritz Klammler <[email protected]>
3736
# Copyright (c) 2016, 2018 Krzesimir Nowak <[email protected]>
3837
# Copyright (c) 2019 Enji Cooper <[email protected]>
38+
# Copyright (c) 2020 Jason Merrill <[email protected]>
39+
# Copyright (c) 2021 Jörn Heusipp <[email protected]>
3940
#
4041
# Copying and distribution of this file, with or without modification, are
4142
# permitted in any medium without royalty provided the copyright notice
4243
# and this notice are preserved. This file is offered as-is, without any
4344
# warranty.
4445

45-
#serial 11
46+
#serial 14
4647

4748
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
4849
dnl (serial version number 13).
4950

50-
dnl Modifications:
51-
dnl Add support for C++20, with no new tests
52-
5351
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
5452
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
5553
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
5654
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
57-
[$1], [20], [ax_cxx_compile_alternatives="20 2a"],
55+
[$1], [20], [ax_cxx_compile_alternatives="20"],
5856
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
5957
m4_if([$2], [], [],
6058
[$2], [ext], [],
@@ -67,6 +65,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
6765
AC_LANG_PUSH([C++])dnl
6866
ac_success=no
6967
68+
m4_if([$2], [], [dnl
69+
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
70+
ax_cv_cxx_compile_cxx$1,
71+
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
72+
[ax_cv_cxx_compile_cxx$1=yes],
73+
[ax_cv_cxx_compile_cxx$1=no])])
74+
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
75+
ac_success=yes
76+
fi])
77+
7078
m4_if([$2], [noext], [], [dnl
7179
if test x$ac_success = xno; then
7280
for alternative in ${ax_cxx_compile_alternatives}; do
@@ -145,33 +153,28 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
145153
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
146154
)
147155

148-
149156
dnl Test body for checking C++14 support
150157

151158
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
152159
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
153160
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
154161
)
155162

163+
dnl Test body for checking C++17 support
164+
156165
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
157166
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
158167
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
159168
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
160169
)
161170

171+
dnl Test body for checking C++20 support
162172

163-
dnl Test body for checking C++20 support: R modification
164173
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
165-
#ifndef __cplusplus
166-
#error "This is not a C++ compiler"
167-
dnl value from 2020-01-14 draft, clang 11 has 202002L
168-
#elif __cplusplus < 201703L
169-
#error "This is not a C++20 compiler"
170-
#else
171174
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
172175
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
173176
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
174-
#endif
177+
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
175178
)
176179

177180

@@ -272,7 +275,7 @@ namespace cxx11
272275
}
273276
274277
int
275-
test(const int c, volatile int v) // 'volatile is deprecated in C++20'
278+
test(const int c, volatile int v)
276279
{
277280
static_assert(is_same<int, decltype(0)>::value == true, "");
278281
static_assert(is_same<int, decltype(c)>::value == false, "");
@@ -970,3 +973,33 @@ namespace cxx17
970973
#endif // __cplusplus < 201703L
971974
972975
]])
976+
977+
978+
dnl Tests for new features in C++20
979+
980+
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
981+
982+
#ifndef __cplusplus
983+
984+
#error "This is not a C++ compiler"
985+
986+
#elif __cplusplus < 202002L
987+
988+
#error "This is not a C++20 compiler"
989+
990+
#else
991+
992+
#include <version>
993+
994+
namespace cxx20
995+
{
996+
997+
// As C++20 supports feature test macros in the standard, there is no
998+
// immediate need to actually test for feature availability on the
999+
// Autoconf side.
1000+
1001+
} // namespace cxx20
1002+
1003+
#endif // __cplusplus < 202002L
1004+
1005+
]])

0 commit comments

Comments
 (0)