[Ada] Add mention of underscore and fix grammar error in doc for -gnatd
[official-gcc.git] / libstdc++-v3 / testsuite / libstdc++-prettyprinters / cxx20.cc
blobd9b47114d570e79e9ea5b649c56d2a744eadc75c
1 // { dg-options "-g -O0 -std=gnu++2a" }
2 // { dg-do run { target c++2a } }
4 // Copyright (C) 2014-2021 Free Software Foundation, Inc.
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.
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.
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/>.
21 #include <compare>
22 #include <iostream>
24 struct X
26 int i;
28 std::weak_ordering operator<=>(X x) const noexcept { return i <=> x.i; }
31 int
32 main()
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" } }
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" } }
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" } }
57 std::cout << "\n";
58 return 0; // Mark SPOT
61 // { dg-final { gdb-test SPOT } }