1 | /* Test <stdbit.h> type-generic macros with -Wconversion. |
---|---|
2 | Copyright (C) 2024 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <stdbit.h> |
20 | #include <support/check.h> |
21 | |
22 | unsigned char uc; |
23 | unsigned short us; |
24 | unsigned int ui; |
25 | unsigned long int ul; |
26 | unsigned long long int ull; |
27 | |
28 | static int |
29 | do_test (void) |
30 | { |
31 | /* The main point of this test is the compile-time test that there |
32 | are no -Wconversion warnings from the type-generic macros, not |
33 | the runtime execution of those macros. */ |
34 | (void) stdc_leading_zeros (uc); |
35 | (void) stdc_leading_zeros (us); |
36 | (void) stdc_leading_zeros (ui); |
37 | (void) stdc_leading_zeros (ul); |
38 | (void) stdc_leading_zeros (ull); |
39 | (void) stdc_leading_ones (uc); |
40 | (void) stdc_leading_ones (us); |
41 | (void) stdc_leading_ones (ui); |
42 | (void) stdc_leading_ones (ul); |
43 | (void) stdc_leading_ones (ull); |
44 | (void) stdc_trailing_zeros (uc); |
45 | (void) stdc_trailing_zeros (us); |
46 | (void) stdc_trailing_zeros (ui); |
47 | (void) stdc_trailing_zeros (ul); |
48 | (void) stdc_trailing_zeros (ull); |
49 | (void) stdc_trailing_ones (uc); |
50 | (void) stdc_trailing_ones (us); |
51 | (void) stdc_trailing_ones (ui); |
52 | (void) stdc_trailing_ones (ul); |
53 | (void) stdc_trailing_ones (ull); |
54 | (void) stdc_first_leading_zero (uc); |
55 | (void) stdc_first_leading_zero (us); |
56 | (void) stdc_first_leading_zero (ui); |
57 | (void) stdc_first_leading_zero (ul); |
58 | (void) stdc_first_leading_zero (ull); |
59 | (void) stdc_first_leading_one (uc); |
60 | (void) stdc_first_leading_one (us); |
61 | (void) stdc_first_leading_one (ui); |
62 | (void) stdc_first_leading_one (ul); |
63 | (void) stdc_first_leading_one (ull); |
64 | (void) stdc_first_trailing_zero (uc); |
65 | (void) stdc_first_trailing_zero (us); |
66 | (void) stdc_first_trailing_zero (ui); |
67 | (void) stdc_first_trailing_zero (ul); |
68 | (void) stdc_first_trailing_zero (ull); |
69 | (void) stdc_first_trailing_one (uc); |
70 | (void) stdc_first_trailing_one (us); |
71 | (void) stdc_first_trailing_one (ui); |
72 | (void) stdc_first_trailing_one (ul); |
73 | (void) stdc_first_trailing_one (ull); |
74 | (void) stdc_count_zeros (uc); |
75 | (void) stdc_count_zeros (us); |
76 | (void) stdc_count_zeros (ui); |
77 | (void) stdc_count_zeros (ul); |
78 | (void) stdc_count_zeros (ull); |
79 | (void) stdc_count_ones (uc); |
80 | (void) stdc_count_ones (us); |
81 | (void) stdc_count_ones (ui); |
82 | (void) stdc_count_ones (ul); |
83 | (void) stdc_count_ones (ull); |
84 | (void) stdc_has_single_bit (uc); |
85 | (void) stdc_has_single_bit (us); |
86 | (void) stdc_has_single_bit (ui); |
87 | (void) stdc_has_single_bit (ul); |
88 | (void) stdc_has_single_bit (ull); |
89 | (void) stdc_bit_width (uc); |
90 | (void) stdc_bit_width (us); |
91 | (void) stdc_bit_width (ui); |
92 | (void) stdc_bit_width (ul); |
93 | (void) stdc_bit_width (ull); |
94 | (void) stdc_bit_floor (uc); |
95 | (void) stdc_bit_floor (us); |
96 | (void) stdc_bit_floor (ui); |
97 | (void) stdc_bit_floor (ul); |
98 | (void) stdc_bit_floor (ull); |
99 | (void) stdc_bit_ceil (uc); |
100 | (void) stdc_bit_ceil (us); |
101 | (void) stdc_bit_ceil (ui); |
102 | (void) stdc_bit_ceil (ul); |
103 | (void) stdc_bit_ceil (ull); |
104 | return 0; |
105 | } |
106 | |
107 | #include <support/test-driver.c> |
108 |