On 22/02/19 01:19 +0000, Jonathan Wakely wrote:
On 05/11/18 14:40 -0500, Tom Honermann wrote:
This patch augments existing tests to validate behavior for char8_t.
In all cases, added test cases are cloned from existing tests for
wchar_t or char16_t.
A few tests required updates to line numbers for diagnostic messages.
I had to make a few changes to this patch. I don't like adding
-fchar8_t to lots of non-C++2a tests, so I removed all the lines
adding that to the dg-options. Instead I either ensured all the checks
for char8_t features are guarded by _GLIBCXX_USE_CHAR8_t, or are in
their own new test files that are compiled using -std=gnu++2a.
I also had to fix the changes to
testsuite/util/testsuite_common_types.h because the additions to the
integral types and the atomic integral types were not in the same
order, so testsuite/29_atomics/atomic/requirements/base_classes.cc
failed when using -std=gnu++2a.
I've committed the attached patch.
Here are some new tests built with -std=gnu++2a, committed to trunk.
commit 4f847a8e46036422867a8169d6bfbe45dc6d633d
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri Feb 22 01:16:15 2019 +0000
Add tests for C++2a content of <atomic> header
* testsuite/29_atomics/headers/atomic/types_std_c++20.cc: New test.
* testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc: New
test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@269091 138bc75d-0d04-0410-961f-82ee72b054a4
diff --git a/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20.cc b/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20.cc
new file mode 100644
index 00000000000..e8a76204f55
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20.cc
@@ -0,0 +1,96 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+// { dg-require-cstdint "" }
+
+// Copyright (C) 2008-2019 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 <atomic>
+
+void test01()
+{
+ using std::memory_order;
+ // TODO add checks for new enumerators memory_order::relaxed etc.
+ // using std::memory_order::relaxed;
+ // using std::memory_order::consume;
+ // using std::memory_order::acquire;
+ // using std::memory_order::release;
+ // using std::memory_order::acq_rel;
+ // using std::memory_order::seq_cst;
+ using std::memory_order_relaxed;
+ using std::memory_order_consume;
+ using std::memory_order_acquire;
+ using std::memory_order_release;
+ using std::memory_order_acq_rel;
+ using std::memory_order_seq_cst;
+
+ using std::atomic_flag;
+
+ // atomics for builtins types
+ using std::atomic_bool;
+ using std::atomic_char;
+ using std::atomic_schar;
+ using std::atomic_uchar;
+ using std::atomic_short;
+ using std::atomic_ushort;
+ using std::atomic_int;
+ using std::atomic_uint;
+ using std::atomic_long;
+ using std::atomic_ulong;
+ using std::atomic_llong;
+ using std::atomic_ullong;
+ using std::atomic_wchar_t;
+#ifdef _GLIBCXX_USE_CHAR8_T
+ using std::atomic_char8_t;
+#endif
+ using std::atomic_char16_t;
+ using std::atomic_char32_t;
+
+ // atomics for standard typedefs
+ using std::atomic_int_least8_t;
+ using std::atomic_uint_least8_t;
+ using std::atomic_int_least16_t;
+ using std::atomic_uint_least16_t;
+ using std::atomic_int_least32_t;
+ using std::atomic_uint_least32_t;
+ using std::atomic_int_least64_t;
+ using std::atomic_uint_least64_t;
+ using std::atomic_int_fast8_t;
+ using std::atomic_uint_fast8_t;
+ using std::atomic_int_fast16_t;
+ using std::atomic_uint_fast16_t;
+ using std::atomic_int_fast32_t;
+ using std::atomic_uint_fast32_t;
+ using std::atomic_int_fast64_t;
+ using std::atomic_uint_fast64_t;
+ using std::atomic_intptr_t;
+ using std::atomic_uintptr_t;
+ using std::atomic_size_t;
+ using std::atomic_ptrdiff_t;
+ using std::atomic_intmax_t;
+ using std::atomic_uintmax_t;
+
+ // DR 2441
+ using std::atomic_int8_t;
+ using std::atomic_uint8_t;
+ using std::atomic_int16_t;
+ using std::atomic_uint16_t;
+ using std::atomic_int32_t;
+ using std::atomic_uint32_t;
+ using std::atomic_int64_t;
+ using std::atomic_uint64_t;
+}
diff --git a/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc b/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc
new file mode 100644
index 00000000000..7f57e16461c
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc
@@ -0,0 +1,83 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+// { dg-require-cstdint "" }
+
+// Copyright (C) 2009-2019 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 <atomic>
+
+void test01()
+{
+ // Not global scoped, only namespace std.
+ using memory_order; // { dg-error "expected nested-name-specifier" }
+ // TODO add checks for new enumerators memory_order::relaxed etc.
+ using memory_order_relaxed; // { dg-error "expected nested-name-specifier" }
+ using memory_order_consume; // { dg-error "expected nested-name-specifier" }
+ using memory_order_acquire; // { dg-error "expected nested-name-specifier" }
+ using memory_order_release; // { dg-error "expected nested-name-specifier" }
+ using memory_order_acq_rel; // { dg-error "expected nested-name-specifier" }
+ using memory_order_seq_cst; // { dg-error "expected nested-name-specifier" }
+
+ using atomic_flag; // { dg-error "expected nested-name-specifier" }
+
+ using atomic_bool; // { dg-error "expected nested-name-specifier" }
+ using atomic_char; // { dg-error "expected nested-name-specifier" }
+ using atomic_schar; // { dg-error "expected nested-name-specifier" }
+ using atomic_uchar; // { dg-error "expected nested-name-specifier" }
+ using atomic_short; // { dg-error "expected nested-name-specifier" }
+ using atomic_ushort; // { dg-error "expected nested-name-specifier" }
+ using atomic_int; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint; // { dg-error "expected nested-name-specifier" }
+ using atomic_long; // { dg-error "expected nested-name-specifier" }
+ using atomic_ulong; // { dg-error "expected nested-name-specifier" }
+ using atomic_llong; // { dg-error "expected nested-name-specifier" }
+ using atomic_ullong; // { dg-error "expected nested-name-specifier" }
+ using atomic_wchar_t; // { dg-error "expected nested-name-specifier" }
+#ifdef _GLIBCXX_USE_CHAR8_T
+ using atomic_char8_t; // { dg-error "expected nested-name-specifier" }
+#endif
+ using atomic_char16_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_char32_t; // { dg-error "expected nested-name-specifier" }
+
+ using atomic_int_least8_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_least8_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_least16_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_least16_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_least32_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_least32_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_least64_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_least64_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_fast8_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_fast8_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_fast16_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_fast16_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_fast32_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_fast32_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_int_fast64_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uint_fast64_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_intptr_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uintptr_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_size_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_ptrdiff_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_intmax_t; // { dg-error "expected nested-name-specifier" }
+ using atomic_uintmax_t; // { dg-error "expected nested-name-specifier" }
+
+ using atomic_address; // { dg-error "expected nested-name-specifier" }
+ // Present in C++0x drafts but not final C++11 standard:
+ using std::atomic_address; // { dg-error "has not been declared" }
+}