[libcxx-commits] [PATCH] D125579: [libc++] Remove overly conservative error in <stdatomic.h>

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 16 12:30:28 PDT 2022


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG193f458c3010: [libc++] Remove overly conservative error in <stdatomic.h> (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125579/new/

https://reviews.llvm.org/D125579

Files:
  libcxx/include/stdatomic.h
  libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp
  libcxx/test/libcxx/atomics/stdatomic.h.syn/incompatible_with_atomic.verify.cpp


Index: libcxx/test/libcxx/atomics/stdatomic.h.syn/incompatible_with_atomic.verify.cpp
===================================================================
--- libcxx/test/libcxx/atomics/stdatomic.h.syn/incompatible_with_atomic.verify.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: libcpp-has-no-threads
-// REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20
-
-// This test ensures that we issue a reasonable diagnostic when using <stdatomic.h> while <atomic>
-// is in use too. Before C++23, this otherwise leads to obscure errors because <stdatomic.h> tries
-// to redefine things defined by <atomic>.
-
-// Ignore additional weird errors that happen when the two headers are mixed.
-// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error -Xclang -verify-ignore-unexpected=warning
-
-#include <atomic>
-#include <stdatomic.h>
-
-// expected-error@*:* {{<stdatomic.h> is incompatible with <atomic> before C++23}}
Index: libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp
===================================================================
--- libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp
+++ libcxx/test/libcxx/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp
@@ -9,9 +9,9 @@
 // UNSUPPORTED: libcpp-has-no-threads
 // REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20
 
-// This test ensures that we issue a reasonable diagnostic when using <atomic> while <stdatomic.h>
-// is in use too. Before C++23, this otherwise leads to obscure errors because <atomic> may try
-// to redefine things defined by <stdatomic.h>.
+// This test ensures that we issue a reasonable diagnostic when including <atomic> after
+// <stdatomic.h> has been included. Before C++23, this otherwise leads to obscure errors
+// because <atomic> may try to redefine things defined by <stdatomic.h>.
 
 // Ignore additional weird errors that happen when the two headers are mixed.
 // ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error -Xclang -verify-ignore-unexpected=warning
Index: libcxx/include/stdatomic.h
===================================================================
--- libcxx/include/stdatomic.h
+++ libcxx/include/stdatomic.h
@@ -226,14 +226,7 @@
 // the header. We do this because Clang has historically shipped a <stdatomic.h>
 // header that would be available in all Standard modes, and we don't want to
 // break that use case.
-//
-// However, if the user has already used <atomic> before, the two headers are
-// incompatible before C++23, so we issue a clear error here to avoid obscure
-// issues down the line.
 # if __has_include_next(<stdatomic.h>)
-#   ifdef _LIBCPP_ATOMIC
-#     error <stdatomic.h> is incompatible with <atomic> before C++23. Please compile with -std=c++23.
-#   endif
 #   include_next <stdatomic.h>
 # endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125579.429815.patch
Type: text/x-patch
Size: 3216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220516/cd1ec68f/attachment.bin>


More information about the libcxx-commits mailing list