summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-12-23 17:47:01 +0100
committerMax Kellermann <max@musicpd.org>2019-12-23 17:53:57 +0100
commita1afe9afc6879960389491b6fb587f14ae1ae5df (patch)
treee0016b1b1f409e81c82a183191305ee35bf28416 /src
parentfe598e7d30d82794560df053623a16fee8d3fb9c (diff)
util/Compiler.h: add gcc_fallthrough
Works around build failures with ccache which may feed processed code to GCC, which doesn't have the "fall through" code comments.
Diffstat (limited to 'src')
-rw-r--r--src/player/Thread.cxx2
-rw-r--r--src/util/Compiler.h6
-rw-r--r--src/util/format.c2
3 files changed, 10 insertions, 0 deletions
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index 05e691bd1..64a502e6d 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -46,6 +46,7 @@
#include "CrossFade.hxx"
#include "tag/Tag.hxx"
#include "Idle.hxx"
+#include "util/Compiler.h"
#include "util/Domain.hxx"
#include "thread/Name.hxx"
#include "Log.hxx"
@@ -1171,6 +1172,7 @@ try {
}
/* fall through */
+ gcc_fallthrough;
case PlayerCommand::PAUSE:
next_song.reset();
diff --git a/src/util/Compiler.h b/src/util/Compiler.h
index 6a64ad098..a97b34529 100644
--- a/src/util/Compiler.h
+++ b/src/util/Compiler.h
@@ -143,6 +143,12 @@
#define gcc_flatten
#endif
+#if CLANG_OR_GCC_VERSION(7,0)
+#define gcc_fallthrough __attribute__((fallthrough))
+#else
+#define gcc_fallthrough
+#endif
+
#ifndef __cplusplus
/* plain C99 has "restrict" */
#define gcc_restrict restrict
diff --git a/src/util/format.c b/src/util/format.c
index 62099b32e..10b53c771 100644
--- a/src/util/format.c
+++ b/src/util/format.c
@@ -19,6 +19,7 @@
*/
#include "format.h"
+#include "util/Compiler.h"
#include <stdbool.h>
#include <stdio.h>
@@ -238,6 +239,7 @@ format_object2(const char *format, const char **last, const void *object,
}
/* fall through */
+ gcc_fallthrough;
default:
/* pass-through non-escaped portions of the format string */