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 | // <atomic> |
10 | |
11 | // template <class T> |
12 | // struct atomic; |
13 | |
14 | // This test checks that we static_assert inside std::atomic<T> when T |
15 | // is not trivially copyable, however Clang will sometimes emit additional |
16 | // errors while trying to instantiate the rest of std::atomic<T>. |
17 | // We silence those to make the test more robust. |
18 | // ADDITIONAL_COMPILE_FLAGS: -Xclang -verify-ignore-unexpected=error |
19 | |
20 | #include <atomic> |
21 | |
22 | struct NotTriviallyCopyable { |
23 | explicit NotTriviallyCopyable(int i) : i_(i) { } |
24 | NotTriviallyCopyable(const NotTriviallyCopyable &rhs) : i_(rhs.i_) { } |
25 | int i_; |
26 | }; |
27 | |
28 | void f() { |
29 | NotTriviallyCopyable x(42); |
30 | std::atomic<NotTriviallyCopyable> a(x); // expected-error@*:* {{std::atomic<T> requires that 'T' be a trivially copyable type}} |
31 | } |
32 | |