Skip to content

Commit

Permalink
[libc++] Remove overly conservative error in <stdatomic.h>
Browse files Browse the repository at this point in the history
As mentionned in D97044, it is fine if users include <atomic> and then
include <stdatomic.h> -- we don't need to error out for that case.

Differential Revision: https://reviews.llvm.org/D125579
  • Loading branch information
ldionne committed May 16, 2022
1 parent efcee4b commit 193f458
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
7 changes: 0 additions & 7 deletions libcxx/include/stdatomic.h
Expand Up @@ -226,14 +226,7 @@ using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
// 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

Expand Down
Expand Up @@ -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
Expand Down

This file was deleted.

0 comments on commit 193f458

Please sign in to comment.