#define __cpp_lib_atomic_flag_test 201907L
_GLIBCXX_ALWAYS_INLINE bool
- test(memory_order __m = memory_order_seq_cst) noexcept
+ test(memory_order __m = memory_order_seq_cst) const noexcept
{
__atomic_flag_data_type __v;
__atomic_load(&_M_i, &__v, int(__m));
}
_GLIBCXX_ALWAYS_INLINE bool
- test(memory_order __m = memory_order_seq_cst) volatile noexcept
+ test(memory_order __m = memory_order_seq_cst) const volatile noexcept
{
__atomic_flag_data_type __v;
__atomic_load(&_M_i, &__v, int(__m));
+// { dg-options "-std=gnu++2a" }
// { dg-do run { target c++2a } }
// { dg-require-thread-fence "" }
// <http://www.gnu.org/licenses/>.
#include <atomic>
+#include <testsuite_hooks.h>
int main()
{
using namespace std;
- atomic_flag af = ATOMIC_FLAG_INIT;
- if (af.test(memory_order_acquire))
- af.clear(memory_order_release);
+ atomic_flag af0 = ATOMIC_FLAG_INIT;
+ VERIFY( ! af0.test(memory_order_acquire) );
- return 0;
+ atomic_flag af{true};
+ const atomic_flag& caf = af;
+
+ VERIFY( af.test(memory_order_acquire) );
+ VERIFY( caf.test(memory_order_acquire) );
+ af.clear(memory_order_release);
+ VERIFY( ! af.test(memory_order_acquire) );
+ VERIFY( ! caf.test(memory_order_acquire) );
}
+// { dg-options "-std=gnu++2a" }
// { dg-do run { target c++2a } }
// { dg-require-thread-fence "" }
// <http://www.gnu.org/licenses/>.
#include <atomic>
+#include <testsuite_hooks.h>
int main()
{
using namespace std;
- atomic_flag af = ATOMIC_FLAG_INIT;
- if (af.test())
- af.clear();
+ atomic_flag af0 = ATOMIC_FLAG_INIT;
+ VERIFY( ! af0.test(memory_order_acquire) );
- return 0;
+ atomic_flag af{true};
+ const atomic_flag& caf = af;
+
+ VERIFY( af.test() );
+ VERIFY( caf.test() );
+ af.clear();
+ VERIFY( ! af.test() );
+ VERIFY( ! caf.test() );
}