From: Wolfgang Bumiller Date: Sat, 11 Feb 2017 10:58:20 +0000 (+0100) Subject: Add GMQCC_FALLTHROUGH X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a59954da24d69f454ddf93f5df2b9c4ad06156b6;p=xonotic%2Fgmqcc.git Add GMQCC_FALLTHROUGH Fixes #174 --- diff --git a/fold.c b/fold.c index c9f1a06..f10413a 100644 --- a/fold.c +++ b/fold.c @@ -643,8 +643,14 @@ ast_expression *fold_op(fold_t *fold, const oper_info *info, ast_expression **op return NULL; switch(info->operands) { - case 3: if(!c) return NULL; - case 2: if(!b) return NULL; + case 3: + if (!c) + return NULL; + GMQCC_FALLTHROUGH; + case 2: + if (!b) + return NULL; + GMQCC_FALLTHROUGH; case 1: if(!a) { compile_error(fold_ctx(fold), "internal error: fold_op no operands to fold\n"); @@ -790,6 +796,7 @@ static ast_expression *fold_superfluous(ast_expression *left, ast_expression *ri case INSTR_DIV_F: if (swapped) return NULL; + GMQCC_FALLTHROUGH; case INSTR_MUL_F: if (fold_immvalue_float(load) == 1.0f) { ++opts_optimizationcount[OPTIM_PEEPHOLE]; diff --git a/gmqcc.h b/gmqcc.h index c853623..a21ea60 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -103,6 +103,11 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \ #if defined(__GNUC__) || defined(__CLANG__) # define GMQCC_WARN __attribute__((warn_unused_result)) # define GMQCC_USED __attribute__((used)) +# if __GNUC__ >= 7 +# define GMQCC_FALLTHROUGH __attribute__((fallthrough)) +# else +# define GMQCC_FALLTHROUGH +# endif # define GMQCC_FUNCTION __func__ #else # define GMQCC_WARN diff --git a/parser.c b/parser.c index 2dc2550..994c683 100644 --- a/parser.c +++ b/parser.c @@ -694,6 +694,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) case opid2('|','|'): generated_op += 1; /* INSTR_OR */ + GMQCC_FALLTHROUGH; case opid2('&','&'): generated_op += INSTR_AND; if (!(out = fold_op(parser->fold, op, exprs))) { @@ -823,10 +824,13 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) case opid1('>'): generated_op += 1; /* INSTR_GT */ + GMQCC_FALLTHROUGH; case opid1('<'): generated_op += 1; /* INSTR_LT */ + GMQCC_FALLTHROUGH; case opid2('>', '='): generated_op += 1; /* INSTR_GE */ + GMQCC_FALLTHROUGH; case opid2('<', '='): generated_op += INSTR_LE; if (NotSameType(TYPE_FLOAT)) { diff --git a/stat.c b/stat.c index e46102d..e7e5bb4 100644 --- a/stat.c +++ b/stat.c @@ -429,8 +429,10 @@ GMQCC_INLINE size_t util_hthash(hash_table_t *ht, const char *key) { switch (len & 3) { case 3: k ^= tail[2] << 16; + GMQCC_FALLTHROUGH; case 2: k ^= tail[1] << 8; + GMQCC_FALLTHROUGH; case 1: k ^= tail[0]; k *= mask1;