Debian Codegraph @

gcc/testsuite/g++.dg/eh/dfp-2.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 typedef float dec32 __attribute__((mode(SD)));
8 typedef float dec64 __attribute__((mode(DD)));
9 typedef float dec128 __attribute__((mode(TD)));
10
11 int
12 foo (double fp)
13 {
14 if (fp < 32.0)
15 throw (dec32)32;
16 if (fp < 64.0)
17 throw (dec64)64;
18 if (fp < 128.0)
19 throw (dec128)128;
20 return 0;
21 }
22
23 int bar (double fp)
24 {
25 try
26 {
27 foo (fp);
28 abort ();
29 }
30 catch (dec32 df)
31 {
32 if (df != (dec32)32)
33 abort ();
34 }
35 catch (dec64 dd)
36 {
37 if (dd != (dec64)64)
38 abort ();
39 }
40 catch (dec128 dl)
41 {
42 if (dl != (dec128)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 }