]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Add GMQCC_FALLTHROUGH
authorWolfgang Bumiller <wry.git@bumiller.com>
Sat, 11 Feb 2017 10:58:20 +0000 (11:58 +0100)
committerWolfgang Bumiller <wry.git@bumiller.com>
Sat, 11 Feb 2017 11:26:20 +0000 (12:26 +0100)
Fixes #174

fold.c
gmqcc.h
parser.c
stat.c

diff --git a/fold.c b/fold.c
index c9f1a0695c07f8fe1b9c35b62f7bbfab4eaaa360..f10413a0a947d0f17b8b53a292bb3784871e013f 100644 (file)
--- 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 c853623d8d4185ad892b7096c997fef0a2a32f25..a21ea60054bab1506199c14762eabee3053e13ad 100644 (file)
--- 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
index 2dc25508449e2771220d08d5907c3f01799fb183..994c68321428ee538eeb72b0aa7d6abe8e937681 100644 (file)
--- 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 e46102da51d3ec8e337cfb49217615be63af7f56..e7e5bb4143f110c03a02ca4215100346fa4c342a 100644 (file)
--- 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;