[gcc r13-8032] libstdc++: Fix 29_atomics/headers/atomic/types_std_c++2a_neg.cc for C++23
Jonathan Wakely
redi@gcc.gnu.org
Thu Nov 9 08:10:37 GMT 2023
https://gcc.gnu.org/g:4b49dfe2773e064362b13a45c29278094c6a6bb4
commit r13-8032-g4b49dfe2773e064362b13a45c29278094c6a6bb4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Sep 15 21:37:46 2023 +0100
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.
(cherry picked from commit 038c0afa893f8cb2277ff44be3e2c09cfab4bc0c)
Diff:
---
.../testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc b/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc
index 8eba8bfd779..65199ce15e5 100644
--- a/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc
@@ -1,5 +1,8 @@
// { 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.
//
@@ -23,7 +26,7 @@
void test01()
{
// 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 consume = memory_order::consume; // { dg-error "has not been declared" }
constexpr auto acquire = memory_order::acquire; // { dg-error "has not been declared" }
More information about the Libstdc++-cvs
mailing list