Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enable experimental Cxx20 support #4600

Merged
merged 5 commits into from
Dec 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
build: update ax_cxx_compile_stdcxx.m4 to be compatible with c++20
  • Loading branch information
PastaPastaPasta committed Dec 6, 2021
commit 974a5461d36022c0c7d91611626b167a05a1caba
27 changes: 24 additions & 3 deletions build-aux/m4/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard)
# or '14' (for the C++14 standard).
# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard),
# '14' (for the C++14 standard), '17' (for the C++17 standard) or
# '20' (for the C++20 standard)
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
Expand Down Expand Up @@ -46,10 +47,14 @@
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).

dnl Modifications:
dnl Add support for C++20, with no new tests

AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[$1], [20], [ax_cxx_compile_alternatives="20 2a"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
Expand Down Expand Up @@ -154,6 +159,22 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)


dnl Test body for checking C++20 support: R modification
m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
#ifndef __cplusplus
#error "This is not a C++ compiler"
dnl value from 2020-01-14 draft, clang 11 has 202002L
#elif __cplusplus < 201703L
#error "This is not a C++20 compiler"
#else
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
#endif
)


dnl Tests for new features in C++11

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
Expand Down Expand Up @@ -251,7 +272,7 @@ namespace cxx11
}

int
test(const int c, volatile int v)
test(const int c, volatile int v) // 'volatile is deprecated in C++20'
{
static_assert(is_same<int, decltype(0)>::value == true, "");
static_assert(is_same<int, decltype(c)>::value == false, "");
Expand Down