Add GMQCC_FALLTHROUGH

Fixes #174
This commit is contained in:
Wolfgang Bumiller 2017-02-11 11:58:20 +01:00
parent 242604b3ef
commit a59954da24
4 changed files with 20 additions and 2 deletions

11
fold.c
View file

@ -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];

View file

@ -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

View file

@ -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)) {

2
stat.c
View file

@ -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;