]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx20.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / cxx20.cc
CommitLineData
a59c50bd
JW
1// { dg-options "-g -O0 -std=gnu++2a" }
2// { dg-do run { target c++2a } }
3
7adcbafe 4// Copyright (C) 2014-2022 Free Software Foundation, Inc.
a59c50bd
JW
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 3, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <compare>
22#include <iostream>
23
24struct X
25{
26 int i;
27
28 std::weak_ordering operator<=>(X x) const noexcept { return i <=> x.i; }
29};
30
31int
32main()
33{
34 auto c1 = 1 <=> 1;
35// { dg-final { note-test c1 "std::strong_ordering::equal" } }
36 auto c2 = 1 <=> 2;
37// { dg-final { note-test c2 "std::strong_ordering::less" } }
38 auto c3 = 4 <=> 3;
39// { dg-final { note-test c3 "std::strong_ordering::greater" } }
40
41 auto c4 = X{1} <=> X{1};
42// { dg-final { note-test c4 "std::weak_ordering::equivalent" } }
43 auto c5 = X{2} <=> X{3};
44// { dg-final { note-test c5 "std::weak_ordering::less" } }
45 auto c6 = X{2} <=> X{1};
46// { dg-final { note-test c6 "std::weak_ordering::greater" } }
47
48 auto c7 = 0.2 <=> 0.2;
49// { dg-final { note-test c7 "std::partial_ordering::equivalent" } }
50 auto c8 = 2.5 <=> 5.5;
51// { dg-final { note-test c8 "std::partial_ordering::less" } }
52 auto c9 = 7.5 <=> -2.2;
53// { dg-final { note-test c9 "std::partial_ordering::greater" } }
54 auto c10 = 0.0 <=> __builtin_nan("");
55// { dg-final { note-test c10 "std::partial_ordering::unordered" } }
56
57 std::cout << "\n";
58 return 0; // Mark SPOT
59}
60
61// { dg-final { gdb-test SPOT } }