Skip to content
Snippets Groups Projects
Verified Commit 152b2de5 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Enforce C++17 at the compiler level

parent 0c1373bc
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-p ...@@ -25,7 +25,7 @@ AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-p
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14 AX_CXX_COMPILE_STDCXX_17
AC_CANONICAL_HOST AC_CANONICAL_HOST
case ${host_os} in case ${host_os} in
......
...@@ -27,14 +27,15 @@ Copyright: 2008-2009 Thomas Porschberg <thomas@randspringer.de> ...@@ -27,14 +27,15 @@ Copyright: 2008-2009 Thomas Porschberg <thomas@randspringer.de>
License: FSFAP License: FSFAP
Files: m4/ax_cxx_compile_stdcxx.m4 Files: m4/ax_cxx_compile_stdcxx.m4
m4/ax_cxx_compile_stdcxx_14.m4 m4/ax_cxx_compile_stdcxx_17.m4
Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com> Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
2012 Zack Weinberg <zackw@panix.com> 2012 Zack Weinberg <zackw@panix.com>
2013 Roy Stogner <roystgnr@ices.utexas.edu> 2013 Roy Stogner <roystgnr@ices.utexas.edu>
2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
2015 Paul Norman <penorman@mac.com> 2015 Paul Norman <penorman@mac.com>
2015 Moritz Klammler <moritz@klammler.eu> 2015 Moritz Klammler <moritz@klammler.eu>
2016 Krzesimir Nowak <qdlacz@gmail.com> 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
2019 Enji Cooper <yaneurabeya@gmail.com>
License: FSFAP License: FSFAP
Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4 Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4
......
...@@ -33,19 +33,19 @@ ...@@ -33,19 +33,19 @@
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com> # Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com> # Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice # permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 7 #serial 11
dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13). dnl (serial version number 13).
AX_REQUIRE_DEFINED([AC_MSG_WARN])
AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
...@@ -61,14 +61,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl ...@@ -61,14 +61,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
[m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
AC_LANG_PUSH([C++])dnl AC_LANG_PUSH([C++])dnl
ac_success=no ac_success=no
AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
ax_cv_cxx_compile_cxx$1,
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
[ax_cv_cxx_compile_cxx$1=yes],
[ax_cv_cxx_compile_cxx$1=no])])
if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
ac_success=yes
fi
m4_if([$2], [noext], [], [dnl m4_if([$2], [noext], [], [dnl
if test x$ac_success = xno; then if test x$ac_success = xno; then
...@@ -139,7 +131,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl ...@@ -139,7 +131,6 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
[define if the compiler supports basic C++$1 syntax]) [define if the compiler supports basic C++$1 syntax])
fi fi
AC_SUBST(HAVE_CXX$1) AC_SUBST(HAVE_CXX$1)
m4_if([$1], [17], [AC_MSG_WARN([C++17 is not yet standardized, so the checks may change in incompatible ways anytime])])
]) ])
...@@ -199,11 +190,13 @@ namespace cxx11 ...@@ -199,11 +190,13 @@ namespace cxx11
struct Base struct Base
{ {
virtual ~Base() {}
virtual void f() {} virtual void f() {}
}; };
struct Derived : public Base struct Derived : public Base
{ {
virtual ~Derived() override {}
virtual void f() override {} virtual void f() override {}
}; };
...@@ -587,20 +580,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ ...@@ -587,20 +580,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
#error "This is not a C++ compiler" #error "This is not a C++ compiler"
#elif __cplusplus <= 201402L #elif __cplusplus < 201703L
#error "This is not a C++17 compiler" #error "This is not a C++17 compiler"
#else #else
#if defined(__clang__)
#define REALLY_CLANG
#else
#if defined(__GNUC__)
#define REALLY_GCC
#endif
#endif
#include <initializer_list> #include <initializer_list>
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>
...@@ -608,16 +593,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ ...@@ -608,16 +593,12 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
namespace cxx17 namespace cxx17
{ {
#if !defined(REALLY_CLANG)
namespace test_constexpr_lambdas namespace test_constexpr_lambdas
{ {
// TODO: test it with clang++ from git
constexpr int foo = [](){return 42;}(); constexpr int foo = [](){return 42;}();
} }
#endif // !defined(REALLY_CLANG)
namespace test::nested_namespace::definitions namespace test::nested_namespace::definitions
{ {
...@@ -852,12 +833,9 @@ namespace cxx17 ...@@ -852,12 +833,9 @@ namespace cxx17
} }
#if !defined(REALLY_CLANG)
namespace test_template_argument_deduction_for_class_templates namespace test_template_argument_deduction_for_class_templates
{ {
// TODO: test it with clang++ from git
template <typename T1, typename T2> template <typename T1, typename T2>
struct pair struct pair
{ {
...@@ -876,7 +854,6 @@ namespace cxx17 ...@@ -876,7 +854,6 @@ namespace cxx17
} }
} }
#endif // !defined(REALLY_CLANG)
namespace test_non_type_auto_template_parameters namespace test_non_type_auto_template_parameters
{ {
...@@ -890,12 +867,9 @@ namespace cxx17 ...@@ -890,12 +867,9 @@ namespace cxx17
} }
#if !defined(REALLY_CLANG)
namespace test_structured_bindings namespace test_structured_bindings
{ {
// TODO: test it with clang++ from git
int arr[2] = { 1, 2 }; int arr[2] = { 1, 2 };
std::pair<int, int> pr = { 1, 2 }; std::pair<int, int> pr = { 1, 2 };
...@@ -927,14 +901,10 @@ namespace cxx17 ...@@ -927,14 +901,10 @@ namespace cxx17
const auto [ x3, y3 ] = f3(); const auto [ x3, y3 ] = f3();
} }
#endif // !defined(REALLY_CLANG)
#if !defined(REALLY_CLANG)
namespace test_exception_spec_type_system namespace test_exception_spec_type_system
{ {
// TODO: test it with clang++ from git
struct Good {}; struct Good {};
struct Bad {}; struct Bad {};
...@@ -952,7 +922,6 @@ namespace cxx17 ...@@ -952,7 +922,6 @@ namespace cxx17
static_assert (std::is_same_v<Good, decltype(f(g1, g2))>); static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
} }
#endif // !defined(REALLY_CLANG)
namespace test_inline_variables namespace test_inline_variables
{ {
...@@ -977,6 +946,6 @@ namespace cxx17 ...@@ -977,6 +946,6 @@ namespace cxx17
} // namespace cxx17 } // namespace cxx17
#endif // __cplusplus <= 201402L #endif // __cplusplus < 201703L
]]) ]])
# ============================================================================= # =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_17.html
# ============================================================================= # =============================================================================
# #
# SYNOPSIS # SYNOPSIS
# #
# AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional]) # AX_CXX_COMPILE_STDCXX_17([ext|noext], [mandatory|optional])
# #
# DESCRIPTION # DESCRIPTION
# #
# Check for baseline language coverage in the compiler for the C++14 # Check for baseline language coverage in the compiler for the C++17
# standard; if necessary, add switches to CXX and CXXCPP to enable # standard; if necessary, add switches to CXX and CXXCPP to enable
# support. # support.
# #
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++14. The two optional arguments are # macro with the version set to C++17. The two optional arguments are
# forwarded literally as the second and third argument respectively. # forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to # more information. If you want to use this macro, you also need to
...@@ -22,13 +22,14 @@ ...@@ -22,13 +22,14 @@
# LICENSE # LICENSE
# #
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
# #
# Copying and distribution of this file, with or without modification, are # Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice # permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any # and this notice are preserved. This file is offered as-is, without any
# warranty. # warranty.
#serial 5 #serial 2
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_17], [AX_CXX_COMPILE_STDCXX([17], [$1], [$2])])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment