harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 727a19365c777d8ac8443a4f346cc013fe61a5e3
parent 6ede8265f3bd9e9b87d569586bcfddce931886d5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 27 Dec 2021 19:50:35 +0100

src/check: Fix uninitialized warning with btype

src/check.c: In function ‘check_expr_binarithm’:
src/check.c:850:9: error: ‘btype’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  850 |         switch (btype) {
      |         ^~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me>

Diffstat:
Msrc/check.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -748,11 +748,15 @@ check_expr_binarithm(struct context *ctx, expr->binarithm.op = aexpr->binarithm.op; enum { + BT_INVALID = -1, BT_NUMERIC, BT_LOGICAL, BT_COMPARISON, BT_EQUALITY, } btype; + + btype = BT_INVALID; + switch (expr->binarithm.op) { // Numeric arithmetic case BIN_BAND: @@ -880,6 +884,9 @@ check_expr_binarithm(struct context *ctx, type_storage_unparse(type_dealias(p)->storage)); } break; + case BT_INVALID: + abort(); + break; } lvalue = lower_implicit_cast(p, lvalue); rvalue = lower_implicit_cast(p, rvalue);