Add tests for C++2a content of <atomic> header
authorJonathan Wakely <jwakely@redhat.com>
Fri, 22 Feb 2019 01:16:15 +0000 (01:16 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Fri, 22 Feb 2019 01:16:15 +0000 (01:16 +0000)
* 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.

From-SVN: r269091

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20.cc [new file with mode: 0644]
libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc [new file with mode: 0644]

index 3980774df93f414c916fa08b4184bc9137bc2335..eb68aba953be70e7fccda2d4fe7ae274f89749a9 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-21  Jonathan Wakely  <jwakely@redhat.com>
+
+       * 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.
+
 2019-02-22  Tom Honermann  <tom@honermann.net>
 
        * python/libstdcxx/v6/printers.py (register_type_printers): Add type
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 (file)
index 0000000..e8a7620
--- /dev/null
@@ -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 (file)
index 0000000..7f57e16
--- /dev/null
@@ -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" }
+}