From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 0E7243858400; Mon, 10 Oct 2022 00:45:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E7243858400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665362725; bh=itP5lO0AK5j9hRDZy5o513hgRZXtYBtSUkYXYwWLOwM=; h=From:To:Subject:Date:From; b=jhtDGRhk2PIKxotO+cQmPkaNJPvyQ8a7cVyxEqd5BOXxt7x9+FqaM0ayvGIFbAPq1 LFV31mYqS4elGFNm1UrRKoPKUCM7P/AF4loXwifkjdkSYQLzr4Hho40iXQ02q2ddCV rH3rBQUCBDiMyd/LHMki2u5QS/LYSQLyOWv3V5Q8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] Merge configure.ac from gcc project X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: bbcf4de01867fd2ac2587920d22541db25de68ba X-Git-Newrev: 228cf97dd3c80a9755bfd2b49a7714826f01072d Message-Id: <20221010004525.0E7243858400@sourceware.org> Date: Mon, 10 Oct 2022 00:45:25 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D228cf97dd3c8= 0a9755bfd2b49a7714826f01072d commit 228cf97dd3c80a9755bfd2b49a7714826f01072d Author: Alan Modra Date: Mon Oct 10 11:08:40 2022 +1030 Merge configure.ac from gcc project =20 To merge with gcc's copy of configure.ac we need to revert changes to configure.ac in the following gcc commits: dc832fb39fc0 2022-08-25 fc259b522c0f 2022-06-25 Then reapply configure.ac changes in binutils from these binutils commits: 50ad1254d503 2021-01-09 bb368aad297f 2022-03-11 e5f2f7d901ee 2022-07-26 2cac01e3ffff 2022-09-26 Plus copy over gcc's config/ax_cxx_compile_stdcxx.m4, then regenerate configure. Diff: --- config/ax_cxx_compile_stdcxx.m4 | 979 ++++++++++ configure | 3892 +++++++++++++++++++++++++++++++++++= ---- configure.ac | 320 +++- 3 files changed, 4749 insertions(+), 442 deletions(-) diff --git a/config/ax_cxx_compile_stdcxx.m4 b/config/ax_cxx_compile_stdcxx= .m4 new file mode 100644 index 00000000000..8c55ebd2044 --- /dev/null +++ b/config/ax_cxx_compile_stdcxx.m4 @@ -0,0 +1,979 @@ +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# 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). +# +# The second argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=3Dgnu++11) or a strict conformance mode (e.g. +# -std=3Dc++11). If neither is specified, you get whatever works, with +# preference for no added switch, and then for an extended mode. +# +# The third argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline support for the specified C++ standard is +# required and that the macro should error out if no mode with that +# support is found. If specified 'optional', then configuration proceeds +# regardless, after defining HAVE_CXX${VERSION} if and only if a +# supporting mode is found. +# +# If the fourth argument is an optional CXX/CXXFLAG/CPPFLAG suffix, e.g. +# "_FOR_BUILD" or "_FOR_TARGET". +# +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov +# Copyright (c) 2015 Paul Norman +# Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# +# Copying and distribution of this file, with or without modification, a= re +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 12 + +dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 mac= ro +dnl (serial version number 13). + +AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl + m4_if([$1], [11], [ax_cxx_compile_alternatives=3D"11 0x"], + [$1], [14], [ax_cxx_compile_alternatives=3D"14 1y"], + [$1], [17], [ax_cxx_compile_alternatives=3D"17 1z"], + [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])]= )dnl + m4_if([$2], [], [], + [$2], [ext], [], + [$2], [noext], [], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])= ])dnl + m4_if([$3], [], [ax_cxx_compile_cxx$1_required=3Dtrue], + [$3], [mandatory], [ax_cxx_compile_cxx$1_required=3Dtrue], + [$3], [optional], [ax_cxx_compile_cxx$1_required=3Dfalse], + [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) + AC_LANG_PUSH([C++])dnl + ac_success=3Dno + m4_ifnblank([$4], [dnl + ax_cv_cxx_compile_cxx$1_orig_cxx=3D"$CXX" + ax_cv_cxx_compile_cxx$1_orig_cxxflags=3D"$CXXFLAGS" + ax_cv_cxx_compile_cxx$1_orig_cppflags=3D"$CPPFLAGS" + CXX=3D"$CXX$4" + CXXFLAGS=3D"$CXXFLAGS$4" + CPPFLAGS=3D"$CPPFLAGS$4"]) + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1$4, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_= $1])], + [ax_cv_cxx_compile_cxx$1$4=3Dyes], + [ax_cv_cxx_compile_cxx$1$4=3Dno])]) + if test x$ax_cv_cxx_compile_cxx$1$4 =3D xyes; then + ac_success=3Dyes + fi]) + + m4_if([$2], [noext], [], [dnl + if test x$ac_success =3D xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch=3D"-std=3Dgnu++${alternative}" + cachevar=3DAS_TR_SH([ax_cv_cxx_compile_cxx$1$4_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX=3D"$CXX" + CXX=3D"$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbod= y_$1])], + [eval $cachevar=3Dyes], + [eval $cachevar=3Dno]) + CXX=3D"$ac_save_CXX"]) + if eval test x\$$cachevar =3D xyes; then + CXX=3D"$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP=3D"$CXXCPP $switch" + fi + ac_success=3Dyes + break + fi + done + fi]) + + m4_if([$2], [ext], [], [dnl + if test x$ac_success =3D xno; then + dnl HP's aCC needs +std=3Dc++11 according to: + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Re= lease_Notes/769149-001.pdf + dnl Cray's crayCC needs "-h std=3Dc++11" + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=3Dc++${alternative} +std=3Dc++${alternative} "-h = std=3Dc++${alternative}"; do + cachevar=3DAS_TR_SH([ax_cv_cxx_compile_cxx$1$4_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX=3D"$CXX" + CXX=3D"$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testb= ody_$1])], + [eval $cachevar=3Dyes], + [eval $cachevar=3Dno]) + CXX=3D"$ac_save_CXX"]) + if eval test x\$$cachevar =3D xyes; then + CXX=3D"$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP=3D"$CXXCPP $switch" + fi + ac_success=3Dyes + break + fi + done + if test x$ac_success =3D xyes; then + break + fi + done + fi]) + m4_ifnblank([$4], [dnl + CXX$4=3D"$CXX" + CXXFLAGS$4=3D"$CXXFLAGS" + CPPFLAGS$4=3D"$CPPFLAGS" + CXX=3D"$ax_cv_cxx_compile_cxx$1_orig_cxx" + CXXFLAGS=3D"$ax_cv_cxx_compile_cxx$1_orig_cxxflags" + CPPFLAGS=3D"$ax_cv_cxx_compile_cxx$1_orig_cppflags"]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx$1_required =3D xtrue; then + if test x$ac_success =3D xno; then + AC_MSG_ERROR([*** A compiler with support for C++$1 language feature= s is required.]) + fi + fi + if test x$ac_success =3D xno; then + HAVE_CXX$1$4=3D0 + AC_MSG_NOTICE([No compiler with C++$1 support was found]) + else + HAVE_CXX$1$4=3D1 + AC_DEFINE(HAVE_CXX$1$4,1, + [define if the compiler supports basic C++$1 syntax]) + fi + AC_SUBST(HAVE_CXX$1$4) +]) + + +dnl Test body for checking C++11 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 +) + + +dnl Test body for checking C++14 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 +) + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) + +dnl Tests for new features in C++11 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; + + template < typename T > + struct is_same + { + static const bool value =3D true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + +]]) + + +dnl Tests for new features in C++14 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda =3D [](auto&&... args){ + const auto istiny =3D [](auto x){ + return (sizeof(x) =3D=3D 1UL) ? 1 : 0; + }; + const int aretiny[] =3D { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii =3D 0b0000000000101010; + static_assert(ivii =3D=3D 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length =3D 0UL; + for (auto p =3D s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("x") =3D=3D 1UL, ""); + static_assert(strlen_c("test") =3D=3D 4UL, ""); + static_assert(strlen_c("another\0test") =3D=3D 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x =3D 0; + const auto lambda1 =3D [a =3D x](int b){ return a + b; }; + const auto lambda2 =3D [a =3D lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_separators + { + + constexpr auto ten_million =3D 100'000'000; + static_assert(ten_million =3D=3D 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value =3D false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value =3D true; + }; + + int + test() + { + auto x =3D 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >=3D 201402L + +]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo =3D [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo =3D {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>:= :value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused =3D f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 =3D 42; + }; + + struct base2 + { + base2() { + b3 =3D 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator=3D=3D (const iter& i, const sentinel& s) + { + return i.i =3D=3D s.i; + } + + bool operator!=3D (const iter& i, const sentinel& s) + { + return !(i =3D=3D s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v =3D i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i =3D f(); i > 0) + { + return 3; + } + + switch (auto i =3D f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p =3D pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] =3D { 1, 2 }; + std::pair pr =3D { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] =3D f1(); + auto& [ xr1, yr1 ] =3D f1(); + auto [ x2, y2 ] =3D f2(); + auto& [ xr2, yr2 ] =3D f2(); + const auto [ x3, y3 ] =3D f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L + +]]) diff --git a/configure b/configure index f14e0efd675..4d530e6d21d 100755 --- a/configure +++ b/configure @@ -603,14 +603,17 @@ WINDRES_FOR_TARGET STRIP_FOR_TARGET READELF_FOR_TARGET RANLIB_FOR_TARGET +OTOOL_FOR_TARGET OBJDUMP_FOR_TARGET OBJCOPY_FOR_TARGET NM_FOR_TARGET LIPO_FOR_TARGET LD_FOR_TARGET +DSYMUTIL_FOR_TARGET DLLTOOL_FOR_TARGET AS_FOR_TARGET AR_FOR_TARGET +GDC_FOR_TARGET GOC_FOR_TARGET GFORTRAN_FOR_TARGET GCC_FOR_TARGET @@ -618,8 +621,10 @@ CXX_FOR_TARGET CC_FOR_TARGET RANLIB_PLUGIN_OPTION AR_PLUGIN_OPTION -PKG_CONFIG_PATH +GDCFLAGS +GDC READELF +OTOOL OBJDUMP OBJCOPY WINDMC @@ -629,6 +634,7 @@ RANLIB NM LIPO LD +DSYMUTIL DLLTOOL AS AR @@ -646,12 +652,15 @@ RANLIB_FOR_BUILD NM_FOR_BUILD LD_FOR_BUILD LDFLAGS_FOR_BUILD +GDC_FOR_BUILD GOC_FOR_BUILD GFORTRAN_FOR_BUILD +DSYMUTIL_FOR_BUILD DLLTOOL_FOR_BUILD CXX_FOR_BUILD CXXFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD +CPP_FOR_BUILD CFLAGS_FOR_BUILD CC_FOR_BUILD AS_FOR_BUILD @@ -697,6 +706,8 @@ gmplibs PGO_BUILD_LTO_CFLAGS PGO_BUILD_USE_CFLAGS PGO_BUILD_GEN_CFLAGS +HAVE_CXX11_FOR_BUILD +HAVE_CXX11 do_compare GNATMAKE GNATBIND @@ -788,6 +799,7 @@ with_system_zlib with_zstd enable_as_accelerator_for enable_offload_targets +enable_offload_defaulted enable_gold enable_ld enable_gprofng @@ -804,11 +816,9 @@ enable_pgo_build with_mpc with_mpc_include with_mpc_lib -with_mpfr_dir with_mpfr with_mpfr_include with_mpfr_lib -with_gmp_dir with_gmp with_gmp_include with_gmp_lib @@ -858,6 +868,7 @@ target_configargs AR AS DLLTOOL +DSYMUTIL LD LIPO NM @@ -867,20 +878,24 @@ WINDRES WINDMC OBJCOPY OBJDUMP +OTOOL READELF CC_FOR_TARGET CXX_FOR_TARGET GCC_FOR_TARGET GFORTRAN_FOR_TARGET GOC_FOR_TARGET +GDC_FOR_TARGET AR_FOR_TARGET AS_FOR_TARGET DLLTOOL_FOR_TARGET +DSYMUTIL_FOR_TARGET LD_FOR_TARGET LIPO_FOR_TARGET NM_FOR_TARGET OBJCOPY_FOR_TARGET OBJDUMP_FOR_TARGET +OTOOL_FOR_TARGET RANLIB_FOR_TARGET READELF_FOR_TARGET STRIP_FOR_TARGET @@ -1517,6 +1532,11 @@ Optional Features: enable offloading to devices from comma-separated LIST of TARGET[=3DDIR]. Use optional path to find offload target compiler during the build + --enable-offload-defaulted + If enabled, configured but not installed offload compilers and + libgomp plugins are silently ignored. Useful for distribution + compilers where those are in separate optional packages. + --enable-gold[=3DARG] build gold [ARG=3D{default,yes,no}] --enable-ld[=3DARG] build ld [ARG=3D{default,yes,no}] --enable-gprofng[=3DARG] build gprofng [ARG=3D{yes,no}] @@ -1575,14 +1595,12 @@ Optional Packages: --with-mpc-lib=3DPATH/lib --with-mpc-include=3DPATH specify directory for installed MPC include fi= les --with-mpc-lib=3DPATH specify directory for the installed MPC library - --with-mpfr-dir=3DPATH this option has been REMOVED --with-mpfr=3DPATH specify prefix directory for installed MPFR pa= ckage. Equivalent to --with-mpfr-include=3DPATH/include= plus --with-mpfr-lib=3DPATH/lib --with-mpfr-include=3DPATH specify directory for installed MPFR include fil= es --with-mpfr-lib=3DPATH specify directory for the installed MPFR libra= ry - --with-gmp-dir=3DPATH this option has been REMOVED --with-gmp=3DPATH specify prefix directory for the installed GMP package. Equivalent to --with-gmp-include=3DPATH/include plus @@ -1644,6 +1662,7 @@ Some influential environment variables: AR AR for the host AS AS for the host DLLTOOL DLLTOOL for the host + DSYMUTIL DSYMUTIL for the host LD LD for the host LIPO LIPO for the host NM NM for the host @@ -1653,6 +1672,7 @@ Some influential environment variables: WINDMC WINDMC for the host OBJCOPY OBJCOPY for the host OBJDUMP OBJDUMP for the host + OTOOL OTOOL for the host READELF READELF for the host CC_FOR_TARGET CC for the target @@ -1664,12 +1684,16 @@ Some influential environment variables: GFORTRAN for the target GOC_FOR_TARGET GOC for the target + GDC_FOR_TARGET + GDC for the target AR_FOR_TARGET AR for the target AS_FOR_TARGET AS for the target DLLTOOL_FOR_TARGET DLLTOOL for the target + DSYMUTIL_FOR_TARGET + DSYMUTIL for the target LD_FOR_TARGET LD for the target LIPO_FOR_TARGET @@ -1680,6 +1704,8 @@ Some influential environment variables: OBJCOPY for the target OBJDUMP_FOR_TARGET OBJDUMP for the target + OTOOL_FOR_TARGET + OTOOL for the target RANLIB_FOR_TARGET RANLIB for the target READELF_FOR_TARGET @@ -2790,7 +2816,7 @@ build_tools=3D"build-texinfo build-flex build-bison b= uild-m4 build-fixincludes" =20 # these libraries are used by various programs built for the host environm= ent #f -host_libs=3D"intl libiberty opcodes bfd readline tcl tk itcl libgui zlib l= ibbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv libctf" +host_libs=3D"intl libiberty opcodes bfd readline tcl tk itcl libgui zlib l= ibbacktrace libcpp libcody libdecnumber gmp mpfr mpc isl libiconv libctf" =20 # these tools are built for the host environment # Note, the powerpc-eabi build depends on sim occurring before gdb in orde= r to @@ -2798,7 +2824,7 @@ host_libs=3D"intl libiberty opcodes bfd readline tcl = tk itcl libgui zlib libbacktr # binutils, gas and ld appear in that order because it makes sense to run # "make check" in that particular order. # If --enable-gold is used, "gold" may replace "ld". -host_tools=3D"texinfo flex bison binutils gas ld fixincludes gcc cgen sid = sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools= libcc1 gotools" +host_tools=3D"texinfo flex bison binutils gas ld fixincludes gcc cgen sid = sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools= libcc1 gotools c++tools" =20 # these libraries are built for the target environment, and are built after # the host libraries and the host tools (which may be a cross compiler) @@ -2809,7 +2835,6 @@ target_libraries=3D"target-libgcc \ target-newlib \ target-libgomp \ target-liboffloadmic \ - target-libhsail-rt \ target-libatomic \ target-libitm \ target-libstdc++-v3 \ @@ -2821,7 +2846,9 @@ target_libraries=3D"target-libgcc \ target-libffi \ target-libobjc \ target-libada \ - target-libgo" + target-libgo \ + target-libphobos \ + target-zlib" =20 # these tools are built using the target libraries, and are intended to # run only in the target environment @@ -2935,12 +2962,6 @@ if test "${with_zstd+set}" =3D set; then : fi =20 =20 -# Don't compile the bundled readline/libreadline.a if --with-system-readli= ne -# is provided. -if test x$with_system_readline =3D xyes ; then - noconfigdirs=3D"$noconfigdirs readline" -fi - # some tools are so dependent upon X11 that if we're not building with X, # it's not even worth trying to configure, much less build, that tool. =20 @@ -2995,6 +3016,14 @@ else fi =20 =20 +# Check whether --enable-offload-defaulted was given. +if test "${enable_offload_defaulted+set}" =3D set; then : + enableval=3D$enable_offload_defaulted; enable_offload_defaulted=3D$enabl= eval +else + enable_offload_defaulted=3D +fi + + # Handle --enable-gold, --enable-ld. # --disable-gold [--enable-ld] # Build only ld. Default option. @@ -3029,7 +3058,7 @@ case "${ENABLE_GOLD}" in *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux*= \ | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \ | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \ - | *-*-solaris2* | *-*-nto* | *-*-nacl* | *-*-haiku*) + | *-*-solaris2* | *-*-nto* | *-*-nacl*) case "${target}" in *-*-linux*aout* | *-*-linux*oldld*) ;; @@ -3043,7 +3072,7 @@ case "${ENABLE_GOLD}" in # Check for target supported by gold. case "${target}" in i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \ - | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-*) + | aarch64*-*-* | tilegx*-*-* | mips*-*-* | s390*-*-* | loongarch*-= *-*) configdirs=3D"$configdirs gold" if test x${ENABLE_GOLD} =3D xdefault; then default_ld=3Dgold @@ -3259,7 +3288,7 @@ if test x$enable_libgomp =3D x ; then ;; *-*-darwin* | *-*-aix*) ;; - nvptx*-*-*) + nvptx*-*-* | amdgcn*-*-*) ;; *) noconfigdirs=3D"$noconfigdirs target-libgomp" @@ -3362,29 +3391,6 @@ $as_echo "yes" >&6; } fi fi =20 - -# Disable libhsail-rt on unsupported systems. -if test -d ${srcdir}/libhsail-rt; then - if test x$enable_libhsail_rt =3D x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libhsail-rt = support" >&5 -$as_echo_n "checking for libhsail-rt support... " >&6; } - if (srcdir=3D${srcdir}/libhsail-rt; \ - . ${srcdir}/configure.tgt; \ - test -n "$UNSUPPORTED") - then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - unsupported_languages=3D"$unsupported_languages brig" - # This implicitly disables also target-libhsail-rt as it won't - # get added to the build without BRIG FE. - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - fi - fi -fi - - # Disable libquadmath for some systems. case "${target}" in avr-*-*) @@ -3403,9 +3409,16 @@ case "${target}" in # No hosted I/O support. noconfigdirs=3D"$noconfigdirs target-libssp" ;; + bpf-*-*) + noconfigdirs=3D"$noconfigdirs target-libssp" + ;; powerpc-*-aix* | rs6000-*-aix*) noconfigdirs=3D"$noconfigdirs target-libssp" ;; + pru-*-*) + # No hosted I/O support. + noconfigdirs=3D"$noconfigdirs target-libssp" + ;; rl78-*-*) # libssp uses a misaligned load to trigger a fault, but the RL78 # doesn't fault for those - instead, it gives a build-time error @@ -3419,13 +3432,17 @@ case "${target}" in esac =20 # Disable libstdc++-v3 for some systems. -# Allow user to override this if they pass --enable-libstdc++-v3 +# Allow user to override this if they pass --enable-libstdcxx if test "${ENABLE_LIBSTDCXX}" =3D "default" ; then case "${target}" in *-*-vxworks*) # VxWorks uses the Dinkumware C++ library. noconfigdirs=3D"$noconfigdirs target-libstdc++-v3" ;; + amdgcn*-*-*) + # Not ported/fails to build when using newlib. + noconfigdirs=3D"$noconfigdirs target-libstdc++-v3" + ;; arm*-wince-pe*) # the C++ libraries don't build on top of CE's C libraries noconfigdirs=3D"$noconfigdirs target-libstdc++-v3" @@ -3433,18 +3450,86 @@ if test "${ENABLE_LIBSTDCXX}" =3D "default" ; then avr-*-*) noconfigdirs=3D"$noconfigdirs target-libstdc++-v3" ;; + bpf-*-*) + noconfigdirs=3D"$noconfigdirs target-libstdc++-v3" + ;; ft32-*-*) noconfigdirs=3D"$noconfigdirs target-libstdc++-v3" ;; esac fi =20 +# Disable C++ on systems where it is known to not work. +# For testing, you can override this with --enable-languages=3Dc++. +case ,${enable_languages}, in + *,c++,*) + ;; + *) + case "${target}" in + bpf-*-*) + unsupported_languages=3D"$unsupported_languages c++" + ;; + esac + ;; +esac + +# Disable Objc on systems where it is known to not work. +# For testing, you can override this with --enable-languages=3Dobjc. +case ,${enable_languages}, in + *,objc,*) + ;; + *) + case "${target}" in + bpf-*-*) + unsupported_languages=3D"$unsupported_languages objc" + ;; + esac + ;; +esac + +# Disable D on systems where it is known to not work. +# For testing, you can override this with --enable-languages=3Dd. +case ,${enable_languages}, in + *,d,*) + ;; + *) + case "${target}" in + bpf-*-*) + unsupported_languages=3D"$unsupported_languages d" + ;; + esac + ;; +esac + +# Disable libphobos on unsupported systems. +# For testing, you can override this with --enable-libphobos. +if test -d ${srcdir}/libphobos; then + if test x$enable_libphobos =3D x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libphobos support" = >&5 +$as_echo_n "checking for libphobos support... " >&6; } + if (srcdir=3D${srcdir}/libphobos; \ + . ${srcdir}/configure.tgt; \ + test "$LIBPHOBOS_SUPPORTED" !=3D "yes") + then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + noconfigdirs=3D"$noconfigdirs target-libphobos" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + fi + fi +fi + # Disable Fortran for some systems. case "${target}" in mmix-*-*) # See . unsupported_languages=3D"$unsupported_languages fortran" ;; + bpf-*-*) + unsupported_languages=3D"$unsupported_languages fortran" + ;; esac =20 # Disable libffi for some systems. @@ -3488,6 +3573,12 @@ case "${target}" in arm-wince-pe) noconfigdirs=3D"$noconfigdirs target-libffi" ;; + arm*-*-symbianelf*) + noconfigdirs=3D"$noconfigdirs target-libffi" + ;; + bpf-*-*) + noconfigdirs=3D"$noconfigdirs target-libffi" + ;; cris-*-* | crisv32-*-*) case "${target}" in *-*-linux*) @@ -3534,7 +3625,7 @@ esac # Disable the go frontend on systems where it is known to not work. Please= keep # this in sync with contrib/config-list.mk. case "${target}" in -*-*-darwin* | *-*-cygwin* | *-*-mingw*) +*-*-darwin* | *-*-cygwin* | *-*-mingw* | bpf-* ) unsupported_languages=3D"$unsupported_languages go" ;; esac @@ -3569,6 +3660,9 @@ if test x$enable_libgo =3D x; then *-*-cygwin* | *-*-mingw*) noconfigdirs=3D"$noconfigdirs target-libgo" ;; + bpf-*-*) + noconfigdirs=3D"$noconfigdirs target-libgo" + ;; esac fi =20 @@ -3594,6 +3688,9 @@ case "${target}" in i[3456789]86-*-*) libgloss_dir=3Di386 ;; + loongarch*-*-*) + libgloss_dir=3Dloongarch + ;; m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*) libgloss_dir=3Dm68hc11 ;; @@ -3606,6 +3703,9 @@ case "${target}" in powerpc*-*-*) libgloss_dir=3Drs6000 ;; + pru-*-*) + libgloss_dir=3Dpru + ;; sparc*-*-*) libgloss_dir=3Dsparc ;; @@ -3637,6 +3737,9 @@ case "${target}" in sparc-*-sunos4*) noconfigdirs=3D"$noconfigdirs target-newlib target-libgloss" ;; + bpf-*-*) + noconfigdirs=3D"$noconfigdirs target-newlib target-libgloss" + ;; *-*-aix*) noconfigdirs=3D"$noconfigdirs target-newlib target-libgloss" ;; @@ -3685,6 +3788,8 @@ case "${target}" in noconfigdirs=3D"$noconfigdirs ld gas gdb gprof" noconfigdirs=3D"$noconfigdirs sim target-rda" ;; + amdgcn*-*-*) + ;; arm-*-darwin*) noconfigdirs=3D"$noconfigdirs ld gas gdb gprof" noconfigdirs=3D"$noconfigdirs sim target-rda" @@ -3708,7 +3813,8 @@ case "${target}" in *-*-dragonfly*) ;; *-*-freebsd*) - if test "x$with_gmp" =3D x && test "x$with_gmp_dir" =3D x \ + if test "x$with_gmp" =3D x \ + && ! test -d ${srcdir}/gmp \ && test -f /usr/local/include/gmp.h; then with_gmp=3D/usr/local fi @@ -3748,6 +3854,9 @@ case "${target}" in # newlib is not 64 bit ready noconfigdirs=3D"$noconfigdirs target-newlib target-libgloss" ;; + bpf-*-*) + noconfigdirs=3D"$noconfigdirs target-libobjc target-libbacktrace" + ;; sh*-*-pe|mips*-*-pe|*arm-wince-pe) noconfigdirs=3D"$noconfigdirs tcl tk itcl libgui sim" ;; @@ -3966,6 +4075,11 @@ case "${target}" in wasm32-*-*) noconfigdirs=3D"$noconfigdirs ld" ;; + loongarch*-*-linux*) + ;; + loongarch*-*-*) + noconfigdirs=3D"$noconfigdirs gprof" + ;; esac =20 # If we aren't building newlib, then don't build libgloss, since libgloss @@ -4020,7 +4134,7 @@ fi hppa*-*) host_makefile_frag=3D"config/mh-pa" ;; - *-*-darwin*) + i?86-*-darwin[89]* | i?86-*-darwin1[0-7]* | powerpc*-*-darwin*) host_makefile_frag=3D"config/mh-darwin" ;; powerpc-*-aix*) @@ -4036,9 +4150,12 @@ if test "${build}" !=3D "${host}" ; then AR_FOR_BUILD=3D${AR_FOR_BUILD-ar} AS_FOR_BUILD=3D${AS_FOR_BUILD-as} CC_FOR_BUILD=3D${CC_FOR_BUILD-gcc} + CPP_FOR_BUILD=3D"${CPP_FOR_BUILD-\$(CC_FOR_BUILD) -E}" CXX_FOR_BUILD=3D${CXX_FOR_BUILD-g++} + DSYMUTIL_FOR_BUILD=3D${DSYMUTIL_FOR_BUILD-dsymutil} GFORTRAN_FOR_BUILD=3D${GFORTRAN_FOR_BUILD-gfortran} GOC_FOR_BUILD=3D${GOC_FOR_BUILD-gccgo} + GDC_FOR_BUILD=3D${GDC_FOR_BUILD-gdc} DLLTOOL_FOR_BUILD=3D${DLLTOOL_FOR_BUILD-dlltool} LD_FOR_BUILD=3D${LD_FOR_BUILD-ld} NM_FOR_BUILD=3D${NM_FOR_BUILD-nm} @@ -4050,8 +4167,10 @@ else AS_FOR_BUILD=3D"\$(AS)" CC_FOR_BUILD=3D"\$(CC)" CXX_FOR_BUILD=3D"\$(CXX)" + DSYMUTIL_FOR_BUILD=3D"\$(DSYMUTIL)" GFORTRAN_FOR_BUILD=3D"\$(GFORTRAN)" GOC_FOR_BUILD=3D"\$(GOC)" + GDC_FOR_BUILD=3D"\$(GDC)" DLLTOOL_FOR_BUILD=3D"\$(DLLTOOL)" LD_FOR_BUILD=3D"\$(LD)" NM_FOR_BUILD=3D"\$(NM)" @@ -5564,6 +5683,7 @@ else have_gnat=3Dno fi =20 +ACX_PROG_GDC { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to compare bootstrap= ped objects" >&5 $as_echo_n "checking how to compare bootstrapped objects... " >&6; } if ${gcc_cv_prog_cmp_skip+:} false; then : @@ -5642,188 +5762,2179 @@ $as_echo "$as_me: WARNING: trying to bootstrap a= cross compiler" >&2;} ;; esac =20 -# When bootstrapping with GCC, build stage 1 in C++98 mode to ensure that a -# C++98 compiler can still start the bootstrap. +# When bootstrapping with GCC, build stage 1 in C++11 mode to ensure that a +# C++11 compiler can still start the bootstrap. Otherwise, if building GC= C, +# require C++11 (or higher). if test "$enable_bootstrap:$GXX" =3D "yes:yes"; then - CXX=3D"$CXX -std=3Dgnu++98" -fi + CXX=3D"$CXX -std=3Dc++11" +elif test "$have_compiler" =3D yes; then + ax_cxx_compile_alternatives=3D"11 0x" ax_cxx_compile_cxx11_required= =3Dtrue + ac_ext=3Dcpp +ac_cpp=3D'$CXXCPP $CPPFLAGS' +ac_compile=3D'$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link=3D'$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftes= t.$ac_ext $LIBS >&5' +ac_compiler_gnu=3D$ac_cv_cxx_compiler_gnu + ac_success=3Dno =20 -# Check whether --enable-pgo-build was given. -if test "${enable_pgo_build+set}" =3D set; then : - enableval=3D$enable_pgo_build; enable_pgo_build=3D$enableval + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX suppo= rts C++11 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++11 features by default... " = >&6; } +if ${ax_cv_cxx_compile_cxx11+:} false; then : + $as_echo_n "(cached) " >&6 else - enable_pgo_build=3Dno -fi + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ =20 =20 -# Issue errors and warnings for invalid/strange PGO build combinations. -case "$have_compiler:$host:$target:$enable_pgo_build" in - *:*:*:no) ;; +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. =20 - # Allow the PGO build only if we aren't building a compiler and - # we are in a native configuration. - no:$build:$build:yes | no:$build:$build:lto) ;; +#ifndef __cplusplus =20 - # Disallow the PGO bootstrap if we are building a compiler. - yes:*:*:yes | yes:*:*:lto) - as_fn_error $? "cannot perform the PGO bootstrap when building a compi= ler" "$LINENO" 5 ;; +#error "This is not a C++ compiler" =20 - *) - as_fn_error $? "invalid option for --enable-pgo-build" "$LINENO" 5 - ;; -esac +#elif __cplusplus < 201103L =20 -if test "$enable_pgo_build" !=3D "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler s= upports -fprofile-generate" >&5 -$as_echo_n "checking whether the compiler supports -fprofile-generate... "= >&6; } - old_CFLAGS=3D"$CFLAGS" - PGO_BUILD_GEN_CFLAGS=3D"-fprofile-generate" - CFLAGS=3D"$CFLAGS $PGO_BUILD_CFLAGS" +#error "This is not a C++11 compiler" =20 -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +#else =20 -else - PGO_BUILD_GEN_CFLAGS=3D -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=3D"$old_CFLAGS" - if test -n "$PGO_BUILD_GEN_CFLAGS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - PGO_BUILD_USE_CFLAGS=3D"-fprofile-use" - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "cannot perform the PGO build without -fprofile-generat= e" "$LINENO" 5 - fi +namespace cxx11 +{ =20 - if test "$enable_pgo_build" =3D "lto"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler= supports -flto=3Djobserver -ffat-lto-objects" >&5 -$as_echo_n "checking whether the compiler supports -flto=3Djobserver -ffat= -lto-objects... " >&6; } - old_CFLAGS=3D"$CFLAGS" - PGO_BUILD_LTO_CFLAGS=3D"-flto=3Djobserver -ffat-lto-objects" - CFLAGS=3D"$CFLAGS $PGO_BUILD_LTO_CFLAGS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -int foo; -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : + namespace test_static_assert + { =20 -else - PGO_BUILD_LTO_CFLAGS=3D -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=3D"$old_CFLAGS" - if test -n "$PGO_BUILD_LTO_CFLAGS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: LTO is disabled fo= r the PGO build" >&5 -$as_echo "$as_me: WARNING: LTO is disabled for the PGO build" >&2;} - fi - fi -fi + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; =20 + } =20 + namespace test_final_override + { =20 + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; =20 -# Used for setting $lt_cv_objdir -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -$as_echo_n "checking for objdir... " >&6; } -if ${lt_cv_objdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=3D.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=3D_libs -fi -rmdir .libs 2>/dev/null -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -$as_echo "$lt_cv_objdir" >&6; } -objdir=3D$lt_cv_objdir + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; =20 + } =20 + namespace test_double_right_angle_brackets + { =20 + template < typename T > + struct check {}; =20 + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; =20 -cat >>confdefs.h <<_ACEOF -#define LT_OBJDIR "$lt_cv_objdir/" -_ACEOF + } =20 + namespace test_decltype + { =20 + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } =20 -# Check for GMP, MPFR and MPC -gmplibs=3D"-lmpc -lmpfr -lgmp" -gmpinc=3D -have_gmp=3Dno + } =20 -# Specify a location for mpc -# check for this first so it ends up on the link line before mpfr. + namespace test_type_deduction + { =20 -# Check whether --with-mpc was given. -if test "${with_mpc+set}" =3D set; then : - withval=3D$with_mpc; -fi + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; =20 + template < typename T > + struct is_same + { + static const bool value =3D true; + }; =20 -# Check whether --with-mpc-include was given. -if test "${with_mpc_include+set}" =3D set; then : - withval=3D$with_mpc_include; -fi + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } =20 + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } =20 -# Check whether --with-mpc-lib was given. -if test "${with_mpc_lib+set}" =3D set; then : - withval=3D$with_mpc_lib; -fi + } =20 + namespace test_noexcept + { =20 -if test "x$with_mpc" !=3D x; then - gmplibs=3D"-L$with_mpc/lib $gmplibs" - gmpinc=3D"-I$with_mpc/include $gmpinc" -fi -if test "x$with_mpc_include" !=3D x; then - gmpinc=3D"-I$with_mpc_include $gmpinc" -fi -if test "x$with_mpc_lib" !=3D x; then - gmplibs=3D"-L$with_mpc_lib $gmplibs" -fi -if test "x$with_mpc$with_mpc_include$with_mpc_lib" =3D x && test -d ${srcd= ir}/mpc; then - gmplibs=3D'-L$$r/$(HOST_SUBDIR)/mpc/src/'"$lt_cv_objdir $gmplibs" - gmpinc=3D'-I$$s/mpc/src '"$gmpinc" - # Do not test the mpc version. Assume that it is sufficient, since - # it is in the source tree, and the library has not been built yet - # but it would be included on the link line in the version check below - # hence making the test fail. - have_gmp=3Dyes -fi + int f() { return 0; } + int g() noexcept { return 0; } =20 -# Specify a location for mpfr -# check for this first so it ends up on the link line before gmp. + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); =20 -# Check whether --with-mpfr-dir was given. -if test "${with_mpfr_dir+set}" =3D set; then : - withval=3D$with_mpfr_dir; as_fn_error $? "The --with-mpfr-dir=3DPATH opt= ion has been removed. -Use --with-mpfr=3DPATH or --with-mpfr-include=3DPATH plus --with-mpfr-lib= =3DPATH" "$LINENO" 5 -fi + } =20 + namespace test_constexpr + { =20 + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } =20 -# Check whether --with-mpfr was given. -if test "${with_mpfr+set}" =3D set; then : - withval=3D$with_mpfr; -fi + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx11=3Dyes +else + ax_cv_cxx_compile_cxx11=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11"= >&5 +$as_echo "$ax_cv_cxx_compile_cxx11" >&6; } + if test x$ax_cv_cxx_compile_cxx11 =3D xyes; then + ac_success=3Dyes + fi + + if test x$ac_success =3D xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch=3D"-std=3Dgnu++${alternative}" + cachevar=3D`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX suppo= rts C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... = " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX=3D"$CXX" + CXX=3D"$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; + + template < typename T > + struct is_same + { + static const bool value =3D true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=3Dyes +else + eval $cachevar=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX=3D"$ac_save_CXX" +fi +eval ac_res=3D\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar =3D xyes; then + CXX=3D"$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP=3D"$CXXCPP $switch" + fi + ac_success=3Dyes + break + fi + done + fi + + if test x$ac_success =3D xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=3Dc++${alternative} +std=3Dc++${alternative} "-h = std=3Dc++${alternative}"; do + cachevar=3D`$as_echo "ax_cv_cxx_compile_cxx11_$switch" | $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX sup= ports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... = " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX=3D"$CXX" + CXX=3D"$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; + + template < typename T > + struct is_same + { + static const bool value =3D true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=3Dyes +else + eval $cachevar=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX=3D"$ac_save_CXX" +fi +eval ac_res=3D\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar =3D xyes; then + CXX=3D"$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP=3D"$CXXCPP $switch" + fi + ac_success=3Dyes + break + fi + done + if test x$ac_success =3D xyes; then + break + fi + done + fi + + ac_ext=3Dc +ac_cpp=3D'$CPP $CPPFLAGS' +ac_compile=3D'$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link=3D'$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$= ac_ext $LIBS >&5' +ac_compiler_gnu=3D$ac_cv_c_compiler_gnu + + if test x$ax_cxx_compile_cxx11_required =3D xtrue; then + if test x$ac_success =3D xno; then + as_fn_error $? "*** A compiler with support for C++11 language featu= res is required." "$LINENO" 5 + fi + fi + if test x$ac_success =3D xno; then + HAVE_CXX11=3D0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 suppor= t was found" >&5 +$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + else + HAVE_CXX11=3D1 + +$as_echo "#define HAVE_CXX11 1" >>confdefs.h + + fi + + + + if test "${build}" !=3D "${host}"; then + ax_cxx_compile_alternatives=3D"11 0x" ax_cxx_compile_cxx11_requir= ed=3Dtrue + ac_ext=3Dcpp +ac_cpp=3D'$CXXCPP $CPPFLAGS' +ac_compile=3D'$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link=3D'$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftes= t.$ac_ext $LIBS >&5' +ac_compiler_gnu=3D$ac_cv_cxx_compiler_gnu + ac_success=3Dno + ax_cv_cxx_compile_cxx11_orig_cxx=3D"$CXX" + ax_cv_cxx_compile_cxx11_orig_cxxflags=3D"$CXXFLAGS" + ax_cv_cxx_compile_cxx11_orig_cppflags=3D"$CPPFLAGS" + CXX=3D"$CXX_FOR_BUILD" + CXXFLAGS=3D"$CXXFLAGS_FOR_BUILD" + CPPFLAGS=3D"$CPPFLAGS_FOR_BUILD" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX suppo= rts C++11 features by default" >&5 +$as_echo_n "checking whether $CXX supports C++11 features by default... " = >&6; } +if ${ax_cv_cxx_compile_cxx11_FOR_BUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; + + template < typename T > + struct is_same + { + static const bool value =3D true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ax_cv_cxx_compile_cxx11_FOR_BUILD=3Dyes +else + ax_cv_cxx_compile_cxx11_FOR_BUILD=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cxx_compile_cxx11_= FOR_BUILD" >&5 +$as_echo "$ax_cv_cxx_compile_cxx11_FOR_BUILD" >&6; } + if test x$ax_cv_cxx_compile_cxx11_FOR_BUILD =3D xyes; then + ac_success=3Dyes + fi + + if test x$ac_success =3D xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + switch=3D"-std=3Dgnu++${alternative}" + cachevar=3D`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" | $= as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX suppo= rts C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... = " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX=3D"$CXX" + CXX=3D"$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; + + template < typename T > + struct is_same + { + static const bool value =3D true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=3Dyes +else + eval $cachevar=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX=3D"$ac_save_CXX" +fi +eval ac_res=3D\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar =3D xyes; then + CXX=3D"$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP=3D"$CXXCPP $switch" + fi + ac_success=3Dyes + break + fi + done + fi + + if test x$ac_success =3D xno; then + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=3Dc++${alternative} +std=3Dc++${alternative} "-h = std=3Dc++${alternative}"; do + cachevar=3D`$as_echo "ax_cv_cxx_compile_cxx11_FOR_BUILD_$switch" |= $as_tr_sh` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX sup= ports C++11 features with $switch" >&5 +$as_echo_n "checking whether $CXX supports C++11 features with $switch... = " >&6; } +if eval \${$cachevar+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_CXX=3D"$CXX" + CXX=3D"$CXX $switch" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <=3D sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual ~Base() {} + virtual void f() {} + }; + + struct Derived : public Base + { + virtual ~Derived() override {} + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a =3D 1; + decltype(a) b =3D 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value =3D false; + }; + + template < typename T > + struct is_same + { + static const bool value =3D true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D false, ""); + auto ac =3D c; + auto av =3D v; + auto sumi =3D ac + av + 'x'; + auto sumf =3D ac + av + 1.0; + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D true, ""); + static_assert(is_same::value =3D=3D false, ""); + static_assert(is_same::value =3D=3D true, = ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) =3D=3D false, ""); + static_assert(noexcept(g()) =3D=3D true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") =3D=3D 0UL, ""); + static_assert(strlen_c("1") =3D=3D 1UL, ""); + static_assert(strlen_c("example") =3D=3D 7UL, ""); + static_assert(strlen_c("another\0example") =3D=3D 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value =3D N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i =3D 0; + const int c =3D 0; + static_assert(decltype(f(i))::value =3D=3D 1, ""); + static_assert(decltype(f(c))::value =3D=3D 2, ""); + static_assert(decltype(f(0))::value =3D=3D 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero =3D=3D 0, ""); + static_assert(test::one =3D=3D 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 =3D [](){}; + auto lambda2 =3D lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a =3D [](int i, int j){ return i + j; }(1, 2); + auto b =3D []() -> int { return '0'; }(); + auto c =3D [=3D](){ return a + b; }(); + auto d =3D [&](){ return c; }(); + auto e =3D [a, &b](int x) mutable { + const auto identity =3D [](int y){ return y; }; + for (auto i =3D 0; i < a; ++i) + a +=3D b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary =3D [](){ return 0; }; + const auto unary =3D [](int x){ return x; }; + using nullary_t =3D decltype(nullary); + using unary_t =3D decltype(unary); + const auto higher1st =3D [](nullary_t f){ return f(); }; + const auto higher2nd =3D [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value =3D N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value =3D 0; + }; + + static_assert(sum<>::value =3D=3D 0, ""); + static_assert(sum<1>::value =3D=3D 1, ""); + static_assert(sum<23>::value =3D=3D 23, ""); + static_assert(sum<1, 2>::value =3D=3D 3, ""); + static_assert(sum<5, 5, 11>::value =3D=3D 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value =3D=3D 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfin= ae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::functi= on + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member =3D typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >=3D 201103L + + + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + eval $cachevar=3Dyes +else + eval $cachevar=3Dno +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CXX=3D"$ac_save_CXX" +fi +eval ac_res=3D\$$cachevar + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + if eval test x\$$cachevar =3D xyes; then + CXX=3D"$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP=3D"$CXXCPP $switch" + fi + ac_success=3Dyes + break + fi + done + if test x$ac_success =3D xyes; then + break + fi + done + fi + CXX_FOR_BUILD=3D"$CXX" + CXXFLAGS_FOR_BUILD=3D"$CXXFLAGS" + CPPFLAGS_FOR_BUILD=3D"$CPPFLAGS" + CXX=3D"$ax_cv_cxx_compile_cxx11_orig_cxx" + CXXFLAGS=3D"$ax_cv_cxx_compile_cxx11_orig_cxxflags" + CPPFLAGS=3D"$ax_cv_cxx_compile_cxx11_orig_cppflags" + ac_ext=3Dc +ac_cpp=3D'$CPP $CPPFLAGS' +ac_compile=3D'$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link=3D'$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$= ac_ext $LIBS >&5' +ac_compiler_gnu=3D$ac_cv_c_compiler_gnu + + if test x$ax_cxx_compile_cxx11_required =3D xtrue; then + if test x$ac_success =3D xno; then + as_fn_error $? "*** A compiler with support for C++11 language featu= res is required." "$LINENO" 5 + fi + fi + if test x$ac_success =3D xno; then + HAVE_CXX11_FOR_BUILD=3D0 + { $as_echo "$as_me:${as_lineno-$LINENO}: No compiler with C++11 suppor= t was found" >&5 +$as_echo "$as_me: No compiler with C++11 support was found" >&6;} + else + HAVE_CXX11_FOR_BUILD=3D1 + +$as_echo "#define HAVE_CXX11_FOR_BUILD 1" >>confdefs.h + + fi + + + fi +fi + +# Check whether --enable-pgo-build was given. +if test "${enable_pgo_build+set}" =3D set; then : + enableval=3D$enable_pgo_build; enable_pgo_build=3D$enableval +else + enable_pgo_build=3Dno +fi + + +# Issue errors and warnings for invalid/strange PGO build combinations. +case "$have_compiler:$host:$target:$enable_pgo_build" in + *:*:*:no) ;; + + # Allow the PGO build only if we aren't building a compiler and + # we are in a native configuration. + no:$build:$build:yes | no:$build:$build:lto) ;; + + # Disallow the PGO bootstrap if we are building a compiler. + yes:*:*:yes | yes:*:*:lto) + as_fn_error $? "cannot perform the PGO bootstrap when building a compi= ler" "$LINENO" 5 ;; + + *) + as_fn_error $? "invalid option for --enable-pgo-build" "$LINENO" 5 + ;; +esac + +if test "$enable_pgo_build" !=3D "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler s= upports -fprofile-generate" >&5 +$as_echo_n "checking whether the compiler supports -fprofile-generate... "= >&6; } + old_CFLAGS=3D"$CFLAGS" + PGO_BUILD_GEN_CFLAGS=3D"-fprofile-generate" + CFLAGS=3D"$CFLAGS $PGO_BUILD_CFLAGS" + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + PGO_BUILD_GEN_CFLAGS=3D +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=3D"$old_CFLAGS" + if test -n "$PGO_BUILD_GEN_CFLAGS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + PGO_BUILD_USE_CFLAGS=3D"-fprofile-use" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "cannot perform the PGO build without -fprofile-generat= e" "$LINENO" 5 + fi + + if test "$enable_pgo_build" =3D "lto"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler= supports -flto=3Djobserver -ffat-lto-objects" >&5 +$as_echo_n "checking whether the compiler supports -flto=3Djobserver -ffat= -lto-objects... " >&6; } + old_CFLAGS=3D"$CFLAGS" + PGO_BUILD_LTO_CFLAGS=3D"-flto=3Djobserver -ffat-lto-objects" + CFLAGS=3D"$CFLAGS $PGO_BUILD_LTO_CFLAGS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + PGO_BUILD_LTO_CFLAGS=3D +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=3D"$old_CFLAGS" + if test -n "$PGO_BUILD_LTO_CFLAGS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: LTO is disabled fo= r the PGO build" >&5 +$as_echo "$as_me: WARNING: LTO is disabled for the PGO build" >&2;} + fi + fi +fi + + + + +# Used for setting $lt_cv_objdir +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if ${lt_cv_objdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=3D.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=3D_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=3D$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + +# Check for GMP, MPFR and MPC +gmplibs=3D"-lmpc -lmpfr -lgmp" +gmpinc=3D +have_gmp=3Dno + +# Specify a location for mpc +# check for this first so it ends up on the link line before mpfr. + +# Check whether --with-mpc was given. +if test "${with_mpc+set}" =3D set; then : + withval=3D$with_mpc; +fi + + +# Check whether --with-mpc-include was given. +if test "${with_mpc_include+set}" =3D set; then : + withval=3D$with_mpc_include; +fi + + +# Check whether --with-mpc-lib was given. +if test "${with_mpc_lib+set}" =3D set; then : + withval=3D$with_mpc_lib; +fi + + +if test "x$with_mpc" !=3D x; then + gmplibs=3D"-L$with_mpc/lib $gmplibs" + gmpinc=3D"-I$with_mpc/include $gmpinc" +fi +if test "x$with_mpc_include" !=3D x; then + gmpinc=3D"-I$with_mpc_include $gmpinc" +fi +if test "x$with_mpc_lib" !=3D x; then + gmplibs=3D"-L$with_mpc_lib $gmplibs" +fi +if test "x$with_mpc$with_mpc_include$with_mpc_lib" =3D x && test -d ${srcd= ir}/mpc; then + gmplibs=3D'-L$$r/$(HOST_SUBDIR)/mpc/src/'"$lt_cv_objdir $gmplibs" + gmpinc=3D'-I$$s/mpc/src '"$gmpinc" + # Do not test the mpc version. Assume that it is sufficient, since + # it is in the source tree, and the library has not been built yet + # but it would be included on the link line in the version check below + # hence making the test fail. + have_gmp=3Dyes +fi + +# Specify a location for mpfr +# check for this first so it ends up on the link line before gmp. + +# Check whether --with-mpfr was given. +if test "${with_mpfr+set}" =3D set; then : + withval=3D$with_mpfr; +fi =20 =20 # Check whether --with-mpfr-include was given. @@ -5865,14 +7976,6 @@ fi =20 # Specify a location for gmp =20 -# Check whether --with-gmp-dir was given. -if test "${with_gmp_dir+set}" =3D set; then : - withval=3D$with_gmp_dir; as_fn_error $? "The --with-gmp-dir=3DPATH optio= n has been removed. -Use --with-gmp=3DPATH or --with-gmp-include=3DPATH plus --with-gmp-lib=3DP= ATH" "$LINENO" 5 -fi - - - # Check whether --with-gmp was given. if test "${with_gmp+set}" =3D set; then : withval=3D$with_gmp; @@ -5984,7 +8087,7 @@ int main () { =20 - #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0) + #if MPFR_VERSION < MPFR_VERSION_NUM(3,1,0) choke me #endif =20 @@ -6001,7 +8104,7 @@ int main () { =20 - #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,2) + #if MPFR_VERSION < MPFR_VERSION_NUM(3,1,6) choke me #endif =20 @@ -6094,9 +8197,9 @@ main () int t; mpfr_init (n); mpfr_init (x); - mpfr_atan2 (n, n, x, GMP_RNDN); - mpfr_erfc (n, x, GMP_RNDN); - mpfr_subnormalize (x, t, GMP_RNDN); + mpfr_atan2 (n, n, x, MPFR_RNDN); + mpfr_erfc (n, x, MPFR_RNDN); + mpfr_subnormalize (x, t, MPFR_RNDN); mpfr_clear(n); mpfr_clear(x); mpc_init2 (c, 53); @@ -6127,11 +8230,11 @@ rm -f core conftest.err conftest.$ac_objext \ # The library versions listed in the error message below should match # the HARD-minimums enforced above. if test x$have_gmp !=3D xyes; then - as_fn_error $? "Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.= 8.0+. + as_fn_error $? "Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.= 8.0+. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations. Source code for these libraries can be found at their respective hosting sites as well as at -ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also +https://gcc.gnu.org/pub/gcc/infrastructure/. See also http://gcc.gnu.org/install/prerequisites.html for additional info. If you obtained GMP, MPFR and/or MPC from a vendor distribution package, make sure that you have installed both the libraries and the header @@ -6471,8 +8574,20 @@ fi # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" =3D set; then : enableval=3D$enable_host_shared; host_shared=3D$enableval + case $host in + x86_64-*-darwin* | aarch64-*-darwin*) + if test x$host_shared !=3D xyes ; then + # PIC is the default, and actually cannot be switched off. + echo configure.ac: warning: PIC code is required for the configured= target, host-shared setting ignored. 1>&2 + host_shared=3Dyes + fi ;; + *) ;; + esac else - host_shared=3Dno + case $host in + x86_64-*-darwin* | aarch64-*-darwin*) host_shared=3Dyes ;; + *) host_shared=3Dno ;; + esac fi =20 =20 @@ -6691,10 +8806,32 @@ $as_echo "$as_me: WARNING: GNAT is required to buil= d $language" >&2;} ;; esac =20 + # Disable D if no preexisting GDC is available. + case ${add_this_lang}:${language}:${have_gdc} in + yes:d:no) + [...] [diff truncated at 100000 bytes]