From 15ba35a51bee27c8b7d4c5ef47673de4db6528af Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 12 Aug 2021 08:31:38 +0200 Subject: [PATCH] build: check for C++ 20 and 2b C++20 is released. * configure.ac, m4/bison-cxx-std.m4, tests/atlocal.in, * tests/local.at: Replace 2a with 20, and add support for 2b. --- configure.ac | 3 ++- m4/bison-cxx-std.m4 | 44 ++++++++++++++++++++++++++++++-------------- tests/atlocal.in | 3 ++- tests/local.at | 6 ++++-- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index f4e02dd6..7c641e53 100644 --- a/configure.ac +++ b/configure.ac @@ -84,7 +84,8 @@ BISON_CXXSTD([03]) BISON_CXXSTD([11]) BISON_CXXSTD([14]) BISON_CXXSTD([17]) -BISON_CXXSTD([2a]) +BISON_CXXSTD([20]) +BISON_CXXSTD([2b]) AM_CONDITIONAL([ENABLE_CXX11], [test x"$CXX11_CXXFLAGS" != x]) AM_CONDITIONAL([ENABLE_CXX14], [test x"$CXX14_CXXFLAGS" != x]) AC_LANG_POP([C++]) diff --git a/m4/bison-cxx-std.m4 b/m4/bison-cxx-std.m4 index 6f6717ae..65d59cc7 100644 --- a/m4/bison-cxx-std.m4 +++ b/m4/bison-cxx-std.m4 @@ -7,16 +7,17 @@ # with or without modifications, as long as this notice is preserved. m4_define([_BISON_CXXSTD_98_snippet], -[#include +[[#include +#include typedef std::vector ints; -]) +]]) m4_define([_BISON_CXXSTD_03_snippet], []) m4_define([_BISON_CXXSTD_11_snippet], -[#include +[[#include #include #include #include @@ -66,10 +67,10 @@ m4_define([_BISON_CXXSTD_11_snippet], // GCC 4.8.2 on Solaris 11.3 does not support to_string. auto e = std::to_string(42); -]) +]]) m4_define([_BISON_CXXSTD_14_snippet], -[ // C++14 +[[ // C++14 void mismatch() { using ints = std::vector; @@ -78,20 +79,24 @@ m4_define([_BISON_CXXSTD_14_snippet], std::mismatch(std::begin(v1), std::end(v1), std::begin(v2), std::end(v2)); } -]) +]]) m4_define([_BISON_CXXSTD_17_snippet], -[ // C++17 +[[ // C++17 namespace ns1::ns2::ns3 {} #include auto opt_string = std::optional{}; auto out = std::ostringstream{}; -]) +]]) -m4_define([_BISON_CXXSTD_2A_snippet], -[ // C++2A -]) +m4_define([_BISON_CXXSTD_20_snippet], +[[ // C++20 +]]) + +m4_define([_BISON_CXXSTD_2B_snippet], +[[ // C++2B +]]) m4_define([_BISON_CXXSTD_testbody(98)], @@ -129,14 +134,25 @@ _BISON_CXXSTD_14_snippet _BISON_CXXSTD_17_snippet ])]) -m4_define([_BISON_CXXSTD_testbody(2a)], +m4_define([_BISON_CXXSTD_testbody(20)], +[AC_LANG_PROGRAM([ +_BISON_CXXSTD_98_snippet +_BISON_CXXSTD_03_snippet +_BISON_CXXSTD_11_snippet +_BISON_CXXSTD_14_snippet +_BISON_CXXSTD_17_snippet +_BISON_CXXSTD_20_snippet +])]) + +m4_define([_BISON_CXXSTD_testbody(2b)], [AC_LANG_PROGRAM([ _BISON_CXXSTD_98_snippet _BISON_CXXSTD_03_snippet _BISON_CXXSTD_11_snippet _BISON_CXXSTD_14_snippet _BISON_CXXSTD_17_snippet -_BISON_CXXSTD_2A_snippet +_BISON_CXXSTD_20_snippet +_BISON_CXXSTD_2B_snippet ])]) @@ -148,7 +164,7 @@ m4_define([_BISON_CXXSTD_testbody], # BISON_CXXSTD(STD) # ----------------- -# Check whether the C++ compiler support STD (11, 98, 2a, etc.). +# Check whether the C++ compiler support STD (11, 98, 2b, etc.). # If it does, AC_SUBST 'CXX_CXXFLAGS' to the corresponding flags. AC_DEFUN([BISON_CXXSTD], [AC_REQUIRE([AC_PROG_CXX]) diff --git a/tests/atlocal.in b/tests/atlocal.in index 3481d22b..eabff450 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -60,7 +60,8 @@ fi : ${CXX11_CXXFLAGS='@CXX11_CXXFLAGS@'} : ${CXX14_CXXFLAGS='@CXX14_CXXFLAGS@'} : ${CXX17_CXXFLAGS='@CXX17_CXXFLAGS@'} -: ${CXX2A_CXXFLAGS='@CXX2A_CXXFLAGS@'} +: ${CXX20_CXXFLAGS='@CXX20_CXXFLAGS@'} +: ${CXX2B_CXXFLAGS='@CXX2B_CXXFLAGS@'} # Whether the compiler supports POSIXLY_CORRECT defined. : ${C_COMPILER_POSIXLY_CORRECT='@C_COMPILER_POSIXLY_CORRECT@'} diff --git a/tests/local.at b/tests/local.at index 3cf4a49e..39c9dbcd 100644 --- a/tests/local.at +++ b/tests/local.at @@ -881,7 +881,8 @@ for at_std in '' \ ${CXX11_CXXFLAGS:+"$CXX11_CXXFLAGS"} \ ${CXX14_CXXFLAGS:+"$CXX14_CXXFLAGS"} \ ${CXX17_CXXFLAGS:+"$CXX17_CXXFLAGS"} \ - ${CXX2A_CXXFLAGS:+"$CXX2A_CXXFLAGS"} + ${CXX20_CXXFLAGS:+"$CXX20_CXXFLAGS"} \ + ${CXX2B_CXXFLAGS:+"$CXX2B_CXXFLAGS"} do ]AS_ECHO(["======== Testing with C++ standard flags: '$at_cxx_std'"])[ CXXFLAGS="$at_for_each_std_CXXFLAGS_save $at_std" @@ -1510,7 +1511,8 @@ m4_define([AT_REQUIRE_CXX_STD], [11], [201103], [14], [201402], [17], [201703], - [2a], [201709], + [20], [202002], + [2b], [202100], [m4_fatal([$0: invalid arguments: $@])])[ return 1; #else -- 2.11.4.GIT