Skip to content
Snippets Groups Projects
Commit 038c0afa authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

libstdc++: Fix 29_atomics/headers/atomic/types_std_c++2a_neg.cc for C++23

This test fails when run as C++23 because the <bits/stdc++.h> PCH
includes <stdatomic.h> which declares ::memory_order, invalidating the
test's assumptions. Disable PCH so that the test verifies that <atomic>
doesn't declare ::memory_order, as originally intended.

Also fix the using-declaration which would be invalid even if the type
was declared in the global namespace, and adjust the expected error.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc:
	Fix test to work for C++23 and C++26 too.
parent d7b60202
No related branches found
No related tags found
No related merge requests found
// { dg-options "-std=gnu++2a" } // { dg-options "-std=gnu++2a" }
// { dg-do compile { target c++2a } } // { dg-do compile { target c++20 } }
// Disable PCH because <bits/stdc++.h> includes <stdatomic.h> which declares
// memory_order in the global namespace.
// { dg-add-options no_pch }
// Copyright (C) 2019-2023 Free Software Foundation, Inc. // Copyright (C) 2019-2023 Free Software Foundation, Inc.
// //
...@@ -23,7 +26,7 @@ ...@@ -23,7 +26,7 @@
void test01() void test01()
{ {
// Not global scoped, only namespace std. // Not global scoped, only namespace std.
using memory_order; // { dg-error "expected nested-name-specifier" } using ::memory_order; // { dg-error "has not been declared" }
constexpr auto relaxed = memory_order::relaxed; // { dg-error "has not been declared" } constexpr auto relaxed = memory_order::relaxed; // { dg-error "has not been declared" }
constexpr auto consume = memory_order::consume; // { dg-error "has not been declared" } constexpr auto consume = memory_order::consume; // { dg-error "has not been declared" }
constexpr auto acquire = memory_order::acquire; // { dg-error "has not been declared" } constexpr auto acquire = memory_order::acquire; // { dg-error "has not been declared" }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment