Skip to content

Commit 0e18179

Browse files
nbdd0121jwnrt
authored andcommitted
[toolchain] allow zero-sized arrays
This is a GNU extension, which we disallow by default. However in many cases special-casing 0 makes the code more verbose without any gain, so just enable this extension. The behaviour of this extension is well-specified and consistent across different Unix compilers, and is already used by a lot of projects, so is safe to enable. Signed-off-by: Gary Guo <[email protected]>
1 parent 23db47c commit 0e18179

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sw/device/tests/sleep_pin_mio_dio_val_test.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ OTTF_DEFINE_TEST_CONFIG();
3535
*/
3636

3737
#if defined(OPENTITAN_IS_EARLGREY)
38-
enum { kNumOptOut = 2 };
3938
static const dt_pad_t kOptOut[] = {
4039
kDtPadSpiDeviceSck,
4140
kDtPadSpiDeviceCsb,
4241
};
4342
#elif defined(OPENTITAN_IS_DARJEELING)
44-
enum { kNumOptOut = 0 };
45-
static const dt_pad_t kOptOut[1] = {0};
43+
static const dt_pad_t kOptOut[] = {};
4644
#else
4745
#error Unsupported top
4846
#endif
@@ -143,7 +141,7 @@ bool lowpower_prep(dif_pwrmgr_t *pwrmgr, dif_pinmux_t *pinmux, bool deepsleep) {
143141

144142
LOG_INFO("Selecting PADs retention modes...");
145143

146-
draw_pinmux_ret(kDtPadCount, kPads, kOptOut, kNumOptOut);
144+
draw_pinmux_ret(kDtPadCount, kPads, kOptOut, ARRAYSIZE(kOptOut));
147145

148146
print_chosen_values();
149147

toolchain/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ cc_args(
308308
"-Wno-missing-field-initializers",
309309
"-Wno-sign-compare",
310310
"-Wno-unused-parameter",
311+
"-Wno-gnu-empty-initializer",
312+
"-Wno-zero-length-array",
311313
"-Wstrict-prototypes",
312314
"-Wswitch-default",
313315
"-Wtype-limits",

0 commit comments

Comments
 (0)