1 /* Test that default-initialized DFP values consistently have the least quantum
4 /* { dg-require-effective-target dfp } */
6 extern void exit (int);
7 extern void abort (void);
8 void *memset (void *, int, __SIZE_TYPE__);
9 int memcmp (const void *, const void *, __SIZE_TYPE__);
12 #define TYPE _Decimal32
16 #define ZEROFP 0e-101DF
20 TYPE zero_fp = ZEROFP;
25 struct s { TYPE a, b; };
26 struct s s_default_init;
27 struct s s_empty_init = {};
28 struct s s_first_int = { 0 };
29 struct s s_both_int = { 0, 0 };
32 const TYPE a_default_init[10];
33 const TYPE a_empty_init[10] = {};
34 const TYPE a_first_int[10] = { 0 };
35 const TYPE a_two_int[10] = { 0, 0 };
37 #define CHECK_ZERO_BYTES(expr) \
40 if (memcmp (expr, &zero_bytes, sizeof zero_bytes) != 0) \
43 if (memcmp (&tmp, &zero_bytes, sizeof zero_bytes) != 0) \
48 #define CHECK_INT_BYTES(expr) \
51 if (memcmp (expr, &zero_int, sizeof zero_int) != 0) \
54 if (memcmp (&tmp, &zero_int, sizeof zero_int) != 0) \
62 memset (&zero_bytes, 0, sizeof zero_bytes);
63 if (memcmp (&zero_bytes, &zero_int, sizeof zero_int) == 0)
65 CHECK_ZERO_BYTES (&zero_fp);
66 CHECK_ZERO_BYTES (&default_init);
67 CHECK_ZERO_BYTES (&s_default_init.a);
68 CHECK_ZERO_BYTES (&s_default_init.b);
69 CHECK_ZERO_BYTES (&s_empty_init.a);
70 CHECK_ZERO_BYTES (&s_empty_init.b);
71 CHECK_INT_BYTES (&s_first_int.a);
72 CHECK_ZERO_BYTES (&s_first_int.b);
73 CHECK_INT_BYTES (&s_both_int.a);
74 CHECK_INT_BYTES (&s_both_int.b);
75 CHECK_ZERO_BYTES (&a_default_init[0]);
76 CHECK_ZERO_BYTES (&a_default_init[1]);
77 CHECK_ZERO_BYTES (&a_default_init[2]);
78 CHECK_ZERO_BYTES (&a_default_init[9]);
79 CHECK_ZERO_BYTES (&a_empty_init[0]);
80 CHECK_ZERO_BYTES (&a_empty_init[1]);
81 CHECK_ZERO_BYTES (&a_empty_init[2]);
82 CHECK_ZERO_BYTES (&a_empty_init[9]);
83 CHECK_INT_BYTES (&a_first_int[0]);
84 CHECK_ZERO_BYTES (&a_first_int[1]);
85 CHECK_ZERO_BYTES (&a_first_int[2]);
86 CHECK_ZERO_BYTES (&a_first_int[9]);
87 CHECK_INT_BYTES (&a_two_int[0]);
88 CHECK_INT_BYTES (&a_two_int[1]);
89 CHECK_ZERO_BYTES (&a_two_int[2]);
90 CHECK_ZERO_BYTES (&a_two_int[9]);
92 CHECK_ZERO_BYTES (&s2.a);
93 CHECK_ZERO_BYTES (&s2.b);
95 CHECK_INT_BYTES (&s3.a);
96 CHECK_ZERO_BYTES (&s3.b);
97 struct s s4 = { 0, 0 };
98 CHECK_INT_BYTES (&s4.a);
99 CHECK_INT_BYTES (&s4.b);
102 CHECK_INT_BYTES (&sx.a);
103 CHECK_ZERO_BYTES (&sx.b);
105 CHECK_ZERO_BYTES (&x);
107 CHECK_INT_BYTES (&x);
108 x = s_default_init.a;
109 CHECK_ZERO_BYTES (&x);
110 x = s_default_init.b;
111 CHECK_ZERO_BYTES (&x);