]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/29_atomics/atomic/69769.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 29_atomics / atomic / 69769.cc
CommitLineData
a945c346 1// Copyright (C) 2017-2024 Free Software Foundation, Inc.
25999a11
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
25999a11
JW
18// { dg-do compile { target c++17 } }
19// { dg-require-atomic-builtins "" }
20
21#include <atomic>
22
23void
24test01()
25{
26 std::atomic<void*> p;
27 p.fetch_add(1); // { dg-error "from here" }
28 p.fetch_sub(1); // { dg-error "from here" }
29 p += 1; // { dg-error "from here" }
30 p -= 1; // { dg-error "from here" }
31 ++p; // { dg-error "from here" }
32 p++; // { dg-error "from here" }
33 --p; // { dg-error "from here" }
34 p--; // { dg-error "from here" }
35}
36
37void
38test02()
39{
40 std::atomic<void(*)()> p;
41 p.fetch_add(1); // { dg-error "from here" }
42 p.fetch_sub(1); // { dg-error "from here" }
43 p += 1; // { dg-error "from here" }
44 p -= 1; // { dg-error "from here" }
45 ++p; // { dg-error "from here" }
46 p++; // { dg-error "from here" }
47 --p; // { dg-error "from here" }
48 p--; // { dg-error "from here" }
49}
50
51void
52test03()
53{
54 volatile std::atomic<void*> p;
55 p.fetch_add(1); // { dg-error "from here" }
56 p.fetch_sub(1); // { dg-error "from here" }
57 p += 1; // { dg-error "from here" }
58 p -= 1; // { dg-error "from here" }
59 ++p; // { dg-error "from here" }
60 p++; // { dg-error "from here" }
61 --p; // { dg-error "from here" }
62 p--; // { dg-error "from here" }
63}
64
65void
66test04()
67{
68 volatile std::atomic<void(*)()> p;
69 p.fetch_add(1); // { dg-error "from here" }
70 p.fetch_sub(1); // { dg-error "from here" }
71 p += 1; // { dg-error "from here" }
72 p -= 1; // { dg-error "from here" }
73 ++p; // { dg-error "from here" }
74 p++; // { dg-error "from here" }
75 --p; // { dg-error "from here" }
76 p--; // { dg-error "from here" }
77}
78
79// { dg-prune-output "static assertion failed" }