1// Copyright (C) 2009-2015 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
30using namespace std::decimal;
31
32float f;
33double d;
34long double ld;
35decimal32 d32;
36decimal64 d64;
37decimal128 d128;
38
39void
40foo (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}
62