]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/decimal/cast_neg.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / decimal / cast_neg.cc
1 // Copyright (C) 2009-2019 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.
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
18 // { dg-do compile }
19 // { dg-require-effective-target dfp }
20
21 // ISO/IEC TR 24733 doesn't say explicitly that the conversion from a
22 // decimal floating-point type to a generic float type is prohibited but
23 // it implies that in section 4.3 when it says "In C, objects of decimal
24 // floating-oint type can be converted to generic floating-point type by
25 // means of an explicit cast. In C++ this is not possible." Check that
26 // attempt to do a cast are flagged as errors.
27
28 #include <decimal/decimal>
29
30 using namespace std::decimal;
31
32 float f;
33 double d;
34 long double ld;
35 decimal32 d32;
36 decimal64 d64;
37 decimal128 d128;
38
39 void
40 foo (void)
41 {
42 f = d32; // { dg-error "error" }
43 f = d64; // { dg-error "error" }
44 f = d128; // { dg-error "error" }
45 d = d32; // { dg-error "error" }
46 d = d64; // { dg-error "error" }
47 d = d128; // { dg-error "error" }
48 ld = d32; // { dg-error "error" }
49 ld = d64; // { dg-error "error" }
50 ld = d128; // { dg-error "error" }
51
52 f = (float)d32; // { dg-error "error" }
53 f = (float)d64; // { dg-error "error" }
54 f = (float)d128; // { dg-error "error" }
55 d = (double)d32; // { dg-error "error" }
56 d = (double)d64; // { dg-error "error" }
57 d = (double)d128; // { dg-error "error" }
58 ld = (long double)d32; // { dg-error "error" }
59 ld = (long double)d64; // { dg-error "error" }
60 ld = (long double)d128; // { dg-error "error" }
61 }