Skip to content

Commit fe2b535

Browse files
committed
Merge pull request fmtlib#101 from cppformat/fallthrough
Try detecting clang::fallthrough using __has_cpp_attribute
2 parents 37ad436 + d7fea1b commit fe2b535

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎format.h‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@
8080
# define FMT_HAS_BUILTIN(x) 0
8181
#endif
8282

83+
#ifdef __has_cpp_attribute
84+
# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
85+
#else
86+
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
87+
#endif
88+
8389
#ifndef FMT_USE_VARIADIC_TEMPLATES
8490
// Variadic templates are available in GCC since version 4.4
8591
// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++
@@ -113,6 +119,12 @@
113119
# define FMT_NOEXCEPT(expr)
114120
#endif
115121

122+
#if FMT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
123+
# define FMT_FALLTHROUGH [[clang::fallthrough]]
124+
#else
125+
# define FMT_FALLTHROUGH
126+
#endif
127+
116128
// A macro to disallow the copy constructor and operator= functions
117129
// This should be used in the private: declarations for a class
118130
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
@@ -868,7 +880,7 @@ class ArgVisitor {
868880
switch (arg.type) {
869881
default:
870882
assert(false);
871-
// Fall through.
883+
FMT_FALLTHROUGH;
872884
case Arg::INT:
873885
return FMT_DISPATCH(visit_int(arg.int_value));
874886
case Arg::UINT:

0 commit comments

Comments
 (0)