From 1b5531461507e887d12d6378f1535daccc8bad7b Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Thu, 24 Jul 2025 13:47:10 +0200 Subject: [PATCH] broadcom/compiler: prevent FALLTHROUGH error with C23 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building for the C23 standard, the compiler gives the following error: ----------------------------------------------------------------------- ../src/broadcom/compiler/vir_register_allocate.c ../src/broadcom/compiler/vir_register_allocate.c: In function ‘update_graph_and_reg_classes_for_inst’: ../src/broadcom/compiler/vir_register_allocate.c:1225:44: error: expected statement before ‘;’ token 1225 | FALLTHROUGH; | ^ ../src/broadcom/compiler/vir_register_allocate.c:1225:44: warning: ‘fallthrough’ attribute ignored [-Wattributes] ../src/broadcom/compiler/vir_register_allocate.c:1225:44: error: suggest braces around empty body in an ‘else’ statement [-Werror=empty-body] ../src/broadcom/compiler/vir_register_allocate.c:1222:28: warning: this statement may fall through [-Wimplicit-fallthrough=] 1222 | if (c->devinfo->ver >= 71) | ^ ../src/broadcom/compiler/vir_register_allocate.c:1226:17: note: here 1226 | case 1: | ^~~~ ----------------------------------------------------------------------- Fix that by doing what the compiler suggests, i.e. by using braces around empty body in the ‘else’ statement. Part-of: --- src/broadcom/compiler/vir_register_allocate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/broadcom/compiler/vir_register_allocate.c b/src/broadcom/compiler/vir_register_allocate.c index dfb5b9a989a..cf2ca4e89d2 100644 --- a/src/broadcom/compiler/vir_register_allocate.c +++ b/src/broadcom/compiler/vir_register_allocate.c @@ -1219,10 +1219,11 @@ update_graph_and_reg_classes_for_inst(struct v3d_compile *c, switch (inst->src[0].index) { case 0: /* V3D 7.x doesn't use rf0 for thread payload */ - if (c->devinfo->ver >= 71) + if (c->devinfo->ver >= 71) { break; - else + } else { FALLTHROUGH; + } case 1: case 2: case 3: {