c++: Hash placeholder constraint in ctp_hasher
[official-gcc.git] / gcc / testsuite / gcc.target / arm / fp16-rounding-alt-1.c
blob2ad03afbcd1e4d5f25905a53752a3b34eb321538
1 /* Test that rounding double to __fp16 happens directly, using an example
2 of a number that would round differently if it went from double to
3 __fp16 via float. */
5 /* { dg-do run } */
6 /* { dg-require-effective-target arm_fp16_hw } */
7 /* { dg-require-effective-target arm_fp16_alternative_ok } */
8 /* { dg-options "-std=c99" } */
9 /* { dg-add-options arm_fp16_alternative } */
11 #include <stdlib.h>
13 /* The original double value. */
14 #define ORIG 0x1.0020008p0
16 /* The expected (double)((__fp16)ORIG) value. */
17 #define ROUNDED 0x1.0040000p0
19 typedef union u {
20 __fp16 f;
21 unsigned short h;
22 } ufh;
24 ufh s = { ORIG };
25 ufh r = { ROUNDED };
27 double d = ORIG;
29 int
30 main (void)
32 ufh x;
34 /* Test that the rounding is correct for static initializers. */
35 if (s.h != r.h)
36 abort ();
38 /* Test that the rounding is correct for a casted constant expression
39 not in a static initializer. */
40 x.f = (__fp16)ORIG;
41 if (x.h != r.h)
42 abort ();
44 /* Test that the rounding is correct for a runtime conversion. */
45 x.f = (__fp16)d;
46 if (x.h != r.h)
47 abort ();
49 return 0;