Debian Codegraph @

gcc/testsuite/g++.dg/eh/dfp-1.C

raw
1 // { dg-do run }
2 // { dg-require-effective-target dfp }
3 /* { dg-require-effective-target dfprt } */
4
5 extern "C" void abort ();
6
7 #include <decimal/decimal>
8
9 using namespace std::decimal;
10
11 int
12 foo (double fp)
13 {
14 if (fp < 32.0)
15 throw (decimal32)32;
16 if (fp < 64.0)
17 throw (decimal64)64;
18 if (fp < 128.0)
19 throw (decimal128)128;
20 return 0;
21 }
22
23 int bar (double fp)
24 {
25 try
26 {
27 foo (fp);
28 abort ();
29 }
30 catch (decimal32 df)
31 {
32 if (df != (decimal32)32)
33 abort ();
34 }
35 catch (decimal64 dd)
36 {
37 if (dd != (decimal64)64)
38 abort ();
39 }
40 catch (decimal128 dl)
41 {
42 if (dl != (decimal128)128)
43 abort ();
44 }
45 return 0;
46 }
47
48 int
49 main ()
50 {
51 bar (10.0);
52 bar (20.0);
53 bar (100.0);
54 return 0;
55 }