| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// UNSUPPORTED: no-threads |
| 10 |
// REQUIRES: c++03 || c++11 || c++14 || c++17 || c++20 |
| 11 |
|
| 12 |
// No diagnostic gets emitted when we build with modules. |
| 13 |
// XFAIL: clang-modules-build |
| 14 |
|
| 15 |
// This test ensures that we issue a reasonable diagnostic when including <atomic> after |
| 16 |
// <stdatomic.h> has been included. Before C++23, this otherwise leads to obscure errors |
| 17 |
// because <atomic> may try to redefine things defined by <stdatomic.h>. |
| 18 |
|
| 19 |
// Ignore additional weird errors that happen when the two headers are mixed. |
| 20 |
// ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error -Xclang -verify-ignore-unexpected=warning |
| 21 |
|
| 22 |
#include <stdatomic.h> |
| 23 |
#include <atomic> |
| 24 |
|
| 25 |
// expected-error@*:* {{<atomic> is incompatible with <stdatomic.h> before C++23.}} |