2020-04-22 Jonathan Wakely <jwakely@redhat.com>
+ * include/bits/stl_iterator.h (__cpp_lib_array_constexpr): Define
+ different values for C++17 and C++20, to indicate different feature
+ sets. Update value for C++20 to indicate P1032R1 support.
+ * include/std/version (__cpp_lib_array_constexpr): Likewise.
+ * testsuite/23_containers/array/comparison_operators/constexpr.cc:
+ Check feature test macro.
+ * testsuite/23_containers/array/element_access/constexpr_c++17.cc:
+ New test.
+ * testsuite/23_containers/array/requirements/constexpr_fill.cc: Check
+ feature test macro.
+ * testsuite/23_containers/array/requirements/constexpr_iter.cc: Test
+ in C++17 mode and check feature test macro.
+
* include/std/utility (__cpp_lib_constexpr_algorithms): Do not define
here.
* testsuite/20_util/exchange/constexpr.cc: Do not expect macro to be
# include <type_traits>
#endif
-#if __cplusplus > 201402L
-# define __cpp_lib_array_constexpr 201803
+#if __cplusplus > 201703L
+# define __cpp_lib_array_constexpr 201811L
+#elif __cplusplus == 201703L
+# define __cpp_lib_array_constexpr 201603L
#endif
#if __cplusplus > 201703L
#if _GLIBCXX_HOSTED
#define __cpp_lib_any 201606L
#define __cpp_lib_apply 201603
-#define __cpp_lib_array_constexpr 201803
+#define __cpp_lib_array_constexpr 201603L
#define __cpp_lib_as_const 201510
#define __cpp_lib_boyer_moore_searcher 201603
#define __cpp_lib_chrono 201611
#define __cpp_lib_unwrap_ref 201811L
#if _GLIBCXX_HOSTED
+#undef __cpp_lib_array_constexpr
+#define __cpp_lib_array_constexpr 201811L
#define __cpp_lib_assume_aligned 201811L
#define __cpp_lib_bind_front 201907L
#define __cpp_lib_integer_comparison_functions 202002L
#include <array>
+#ifndef __cpp_lib_array_constexpr
+# error "Feature test macro for array constexpr is missing in <array>"
+#elif __cpp_lib_array_constexpr < 201806L
+# error "Feature test macro for array constexpr has wrong value in <array>"
+#endif
+
constexpr std::array<int, 3> a1{{1, 2, 3}};
constexpr std::array<int, 3> a2{{4, 5, 6}};
constexpr std::array<int, 3> a3{{1, 2, 4}};
--- /dev/null
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+// Copyright (C) 2011-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <array>
+
+#ifndef __cpp_lib_array_constexpr
+# error "Feature test macro for array constexpr is missing in <array>"
+#elif __cpp_lib_array_constexpr < 201603L
+# error "Feature test macro for array constexpr has wrong value in <array>"
+#elif __cpp_lib_array_constexpr > 201603L && __cplusplus == 201703
+# error "Feature test macro for array constexpr has wrong value for C++17"
+#endif
+
+constexpr std::size_t test01()
+{
+ // array
+ typedef std::array<std::size_t, 6> array_type;
+ array_type a = { { 0, 55, 66, 99, 4115, 2 } };
+ auto v1 = a[1];
+ auto v2 = a.at(2);
+ auto v3 = a.front();
+ auto v4 = a.back();
+ return v1 + v2 + v3 + v4;
+}
+
+static_assert( test01() == (55 + 66 + 0 + 2) );
+
+constexpr std::size_t test02()
+{
+ // array
+ typedef std::array<std::size_t, 6> array_type;
+ const array_type a = { { 0, 55, 66, 99, 4115, 2 } };
+ auto v1 = a[1];
+ auto v2 = a.at(2);
+ auto v3 = a.front();
+ auto v4 = a.back();
+ return v1 + v2 + v3 + v4;
+}
+
+static_assert( test02() == (55 + 66 + 0 + 2) );
#include <array>
+#ifndef __cpp_lib_array_constexpr
+# error "Feature test macro for array constexpr is missing in <array>"
+#elif __cpp_lib_array_constexpr < 201811L
+# error "Feature test macro for array constexpr has wrong value in <array>"
+#endif
+
constexpr bool
test_array()
{
-// { dg-options "-std=gnu++2a" }
-// { dg-do compile { target c++2a } }
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++17 } }
//
// Copyright (C) 2019-2020 Free Software Foundation, Inc.
//
#include <array>
+#ifndef __cpp_lib_array_constexpr
+# error "Feature test macro for array constexpr is missing in <array>"
+#elif __cpp_lib_array_constexpr < 201603L
+# error "Feature test macro for array constexpr has wrong value in <array>"
+#elif __cpp_lib_array_constexpr > 201603L && __cplusplus == 201703
+# error "Feature test macro for array constexpr has wrong value for C++17"
+#endif
+
constexpr int
test()
{