summaryrefslogtreecommitdiff
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorEmil Renner Berthing <esmil@mailme.dk>2019-11-28 12:47:21 +0100
committerEmil Renner Berthing <esmil@mailme.dk>2020-10-22 11:53:16 +0200
commitccd92335a11f03597f94da2ac937811ff3fa50cf (patch)
tree2a31448c25724edf2ff5213b1cc1b52dd5ff0f82 /py/mpconfig.h
parentdde3db21fcd8d810bb59e0c56dfa5fd9208e1544 (diff)
py, extmod: Introduce and use MP_FALLTHROUGH macro.
Newer GCC versions are able to warn about switch cases that fall through. This is usually a sign of a forgotten break statement, but in the few cases where a fall through is intended we annotate it with this macro to avoid the warning.
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index cc83f3850..854188b66 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -1643,6 +1643,13 @@ typedef double mp_float_t;
#endif
#endif
+// Explicitly annotate switch case fall throughs
+#if defined(__GNUC__) && __GNUC__ >= 7
+#define MP_FALLTHROUGH __attribute__((fallthrough));
+#else
+#define MP_FALLTHROUGH
+#endif
+
#ifndef MP_HTOBE16
#if MP_ENDIANNESS_LITTLE
#define MP_HTOBE16(x) ((uint16_t)((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)))