PR c/61852
[official-gcc.git] / libstdc++-v3 / testsuite / decimal / mixed-mode-cmp_neg.cc
blob6dd642822f81d4b3f353b3cb2c54deaf9469b9f6
1 // Copyright (C) 2009-2014 Free Software Foundation, Inc.
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.
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.
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/>.
18 // { dg-do compile }
19 // { dg-require-effective-target dfp }
21 // Test that binary comparison operators do not accept mixed decimal
22 // and generic floating-point operands. This isn't explicity prohibited
23 // in ISO/IEC TR 24733 but it is prohibited in C, and in C++ there should
24 // not be an implicit conversion from a decimal floating-point type to a
25 // generic floating-point type.
27 #include <decimal/decimal>
29 using namespace std::decimal;
31 decimal32 a32, b32, c32;
32 decimal64 a64, b64, c64;
33 decimal128 a128, b128, c128;
34 float f;
35 double d;
36 long double ld;
37 bool b1, b2, b3, b4, b5, b6;
39 void
40 bad_eq (void)
42 b1 = b32 == f; // { dg-error "error" }
43 b2 = ld == b32; // { dg-error "error" }
44 b3 = b64 == d; // { dg-error "error" }
45 b4 = ld == b64; // { dg-error "error" }
46 b5 = b128 == ld; // { dg-error "error" }
47 b6 = d == b128; // { dg-error "error" }
50 void
51 bad_ne (void)
53 b1 = b32 != f; // { dg-error "error" }
54 b2 = ld != b32; // { dg-error "error" }
55 b3 = b64 != d; // { dg-error "error" }
56 b4 = ld != b64; // { dg-error "error" }
57 b5 = b128 != ld; // { dg-error "error" }
58 b6 = d != b128; // { dg-error "error" }
61 void
62 bad_lt (void)
64 b1 = b32 < f; // { dg-error "error" }
65 b2 = ld < b32; // { dg-error "error" }
66 b3 = b64 < d; // { dg-error "error" }
67 b4 = ld < b64; // { dg-error "error" }
68 b5 = b128 < ld; // { dg-error "error" }
69 b6 = d < b128; // { dg-error "error" }
72 void
73 bad_le (void)
75 b1 = b32 <= f; // { dg-error "error" }
76 b2 = ld <= b32; // { dg-error "error" }
77 b3 = b64 <= d; // { dg-error "error" }
78 b4 = ld <= b64; // { dg-error "error" }
79 b5 = b128 <= ld; // { dg-error "error" }
80 b6 = d <= b128; // { dg-error "error" }
83 void
84 bad_gt (void)
86 b1 = b32 > f; // { dg-error "error" }
87 b2 = ld > b32; // { dg-error "error" }
88 b3 = b64 > d; // { dg-error "error" }
89 b4 = ld > b64; // { dg-error "error" }
90 b5 = b128 > ld; // { dg-error "error" }
91 b6 = d > b128; // { dg-error "error" }
94 void
95 bad_ge (void)
97 b1 = b32 >= f; // { dg-error "error" }
98 b2 = ld >= b32; // { dg-error "error" }
99 b3 = b64 >= d; // { dg-error "error" }
100 b4 = ld >= b64; // { dg-error "error" }
101 b5 = b128 >= ld; // { dg-error "error" }
102 b6 = d >= b128; // { dg-error "error" }