Fix all warnings about switch-case fallthrough
Replace 'fallthrough intended' comments with a dedicated macro
that the compiler can see (or remove those comments when they don't
provide value).
Change-Id: Ib6361e15ff078378921c9e2b654bff63cf497f5f
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index fa5e2ee..1666ffc 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -43,6 +43,20 @@
extern "C" {
#endif
+#if defined(__clang__) && defined(__has_warning)
+#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
+#define AOM_FALLTHROUGH_INTENDED [[clang::fallthrough]] // NOLINT
+#endif
+#elif defined(__GNUC__) && __GNUC__ >= 7
+#define AOM_FALLTHROUGH_INTENDED [[gnu::fallthrough]] // NOLINT
+#endif
+
+#ifndef AOM_FALLTHROUGH_INTENDED
+#define AOM_FALLTHROUGH_INTENDED \
+ do { \
+ } while (0)
+#endif
+
#define CDEF_MAX_STRENGTHS 16
#define REF_FRAMES_LOG2 3
@@ -998,6 +1012,7 @@
switch (partition) {
case PARTITION_SPLIT:
if (bsize != BLOCK_8X8) break;
+ AOM_FALLTHROUGH_INTENDED;
case PARTITION_NONE:
case PARTITION_HORZ:
case PARTITION_VERT:
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index ca081d6..fa39e46 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -3766,7 +3766,7 @@
(1 << GM_ALPHA_PREC_BITS),
(gm->wmmat[5] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS));
}
- // Fallthrough intended
+ AOM_FALLTHROUGH_INTENDED;
case TRANSLATION:
trans_bits = (gm->wmtype == TRANSLATION)
? GM_ABS_TRANS_ONLY_BITS - !allow_hp
@@ -3782,7 +3782,7 @@
(1 << trans_bits) + 1, SUBEXPFIN_K,
(ref_gm->wmmat[1] >> trans_prec_diff),
(gm->wmmat[1] >> trans_prec_diff));
- // Fallthrough intended
+ AOM_FALLTHROUGH_INTENDED;
case IDENTITY: break;
default: assert(0);
}
diff --git a/av1/encoder/global_motion.c b/av1/encoder/global_motion.c
index 58a29c3..53db5e8 100644
--- a/av1/encoder/global_motion.c
+++ b/av1/encoder/global_motion.c
@@ -110,11 +110,18 @@
static void force_wmtype(WarpedMotionParams *wm, TransformationType wmtype) {
switch (wmtype) {
- case IDENTITY: wm->wmmat[0] = 0; wm->wmmat[1] = 0;
+ case IDENTITY:
+ wm->wmmat[0] = 0;
+ wm->wmmat[1] = 0;
+ AOM_FALLTHROUGH_INTENDED;
case TRANSLATION:
wm->wmmat[2] = 1 << WARPEDMODEL_PREC_BITS;
wm->wmmat[3] = 0;
- case ROTZOOM: wm->wmmat[4] = -wm->wmmat[3]; wm->wmmat[5] = wm->wmmat[2];
+ AOM_FALLTHROUGH_INTENDED;
+ case ROTZOOM:
+ wm->wmmat[4] = -wm->wmmat[3];
+ wm->wmmat[5] = wm->wmmat[2];
+ AOM_FALLTHROUGH_INTENDED;
case AFFINE: wm->wmmat[6] = wm->wmmat[7] = 0; break;
default: assert(0);
}
diff --git a/av1/encoder/hybrid_fwd_txfm.c b/av1/encoder/hybrid_fwd_txfm.c
index 74bb439..0028edc 100644
--- a/av1/encoder/hybrid_fwd_txfm.c
+++ b/av1/encoder/hybrid_fwd_txfm.c
@@ -179,7 +179,6 @@
case ADST_DCT:
case DCT_ADST:
case ADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
case FLIPADST_DCT:
@@ -187,7 +186,6 @@
case FLIPADST_FLIPADST:
case ADST_FLIPADST:
case FLIPADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
// use the c version for anything including identity for now
@@ -198,7 +196,6 @@
case V_FLIPADST:
case H_FLIPADST:
case IDTX:
- // fallthrough intended
av1_fwd_txfm2d_4x4_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
default: assert(0);
@@ -257,7 +254,6 @@
case ADST_DCT:
case DCT_ADST:
case ADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
case FLIPADST_DCT:
@@ -265,7 +261,6 @@
case FLIPADST_FLIPADST:
case ADST_FLIPADST:
case FLIPADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
// use the c version for anything including identity for now
@@ -276,7 +271,6 @@
case V_FLIPADST:
case H_FLIPADST:
case IDTX:
- // fallthrough intended
av1_fwd_txfm2d_8x8_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
default: assert(0);
@@ -293,7 +287,6 @@
case ADST_DCT:
case DCT_ADST:
case ADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
case FLIPADST_DCT:
@@ -301,7 +294,6 @@
case FLIPADST_FLIPADST:
case ADST_FLIPADST:
case FLIPADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
// use the c version for anything including identity for now
@@ -312,7 +304,6 @@
case V_FLIPADST:
case H_FLIPADST:
case IDTX:
- // fallthrough intended
av1_fwd_txfm2d_16x16_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
default: assert(0);
@@ -329,7 +320,6 @@
case ADST_DCT:
case DCT_ADST:
case ADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
case FLIPADST_DCT:
@@ -337,7 +327,6 @@
case FLIPADST_FLIPADST:
case ADST_FLIPADST:
case FLIPADST_ADST:
- // fallthrough intended
av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
// use the c version for anything including identity for now
@@ -348,7 +337,6 @@
case V_FLIPADST:
case H_FLIPADST:
case IDTX:
- // fallthrough intended
av1_fwd_txfm2d_32x32_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
break;
default: assert(0);