aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-05-29 15:09:48 -0400
committerDavid Robillard <d@drobilla.net>2021-05-31 11:30:12 -0400
commit8fc6ee6582d77d04e7b500932b77e6c48c8c39a6 (patch)
tree9bb5b0dc9460466acbd0ad4359027a83b0abe6ee
parent0ea841d621f81240241fc36a0e6153f57ab88020 (diff)
downloadserd-8fc6ee6582d77d04e7b500932b77e6c48c8c39a6.tar.gz
serd-8fc6ee6582d77d04e7b500932b77e6c48c8c39a6.tar.bz2
serd-8fc6ee6582d77d04e7b500932b77e6c48c8c39a6.zip
Fix unannotated switch fallthroughs
Unfortunately, clang does not support doing this with comments, requiring yet more preprocessor gunk.
-rw-r--r--src/n3.c23
-rw-r--r--src/string.c11
-rw-r--r--wscript1
3 files changed, 27 insertions, 8 deletions
diff --git a/src/n3.c b/src/n3.c
index fbe3c392..f56da170 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -30,6 +30,16 @@
#include <stdlib.h>
#include <string.h>
+#if defined(__clang__) && __clang_major__ >= 10
+# define SERD_FALLTHROUGH __attribute__((fallthrough))
+_Pragma("clang diagnostic push")
+_Pragma("clang diagnostic ignored \"-Wmissing-declarations\"")
+#elif defined(__GNUC__) && __GNUC__ >= 7
+# define SERD_FALLTHROUGH __attribute__((fallthrough))
+#else
+# define SERD_FALLTHROUGH
+#endif
+
#define TRY(st, exp) \
do { \
if (((st) = (exp))) { \
@@ -118,20 +128,20 @@ read_UCHAR(SerdReader* reader, Ref dest, uint32_t* char_code)
buf[3] = (uint8_t)(0x80u | (c & 0x3Fu));
c >>= 6;
c |= (16 << 12); // set bit 4
- /* fallthru */
+ SERD_FALLTHROUGH;
case 3:
buf[2] = (uint8_t)(0x80u | (c & 0x3Fu));
c >>= 6;
c |= (32 << 6); // set bit 5
- /* fallthru */
+ SERD_FALLTHROUGH;
case 2:
buf[1] = (uint8_t)(0x80u | (c & 0x3Fu));
c >>= 6;
c |= 0xC0; // set bits 6 and 7
- /* fallthru */
+ SERD_FALLTHROUGH;
case 1:
buf[0] = (uint8_t)c;
- /* fallthru */
+ SERD_FALLTHROUGH;
default:
break;
}
@@ -873,6 +883,7 @@ read_number(SerdReader* reader, Ref* dest, Ref* datatype, bool* ate_dot)
case '+':
case '-':
push_byte(reader, *dest, eat_byte_safe(reader, c));
+ break;
default:
break;
}
@@ -1718,3 +1729,7 @@ read_nquadsDoc(SerdReader* reader)
}
return SERD_SUCCESS;
}
+
+#if defined(__clang__) && __clang_major__ >= 10
+_Pragma("clang diagnostic pop")
+#endif
diff --git a/src/string.c b/src/string.c
index b83ad58f..6c834cc4 100644
--- a/src/string.c
+++ b/src/string.c
@@ -66,6 +66,7 @@ serd_update_flags(const uint8_t c, SerdNodeFlags* const flags)
break;
case '"':
*flags |= SERD_HAS_QUOTE;
+ break;
default:
break;
}
@@ -120,16 +121,20 @@ static inline double
read_sign(const char** sptr)
{
double sign = 1.0;
+
switch (**sptr) {
case '-':
sign = -1.0;
- // fallthru
+ ++(*sptr);
+ break;
case '+':
++(*sptr);
- // fallthru
+ break;
default:
- return sign;
+ break;
}
+
+ return sign;
}
double
diff --git a/wscript b/wscript
index e6397cb9..1735b867 100644
--- a/wscript
+++ b/wscript
@@ -65,7 +65,6 @@ def configure(conf):
'-Wno-disabled-macro-expansion',
'-Wno-double-promotion',
'-Wno-format-nonliteral',
- '-Wno-implicit-fallthrough',
'-Wno-nullability-extension',
'-Wno-nullable-to-nonnull-conversion',
'-Wno-padded',