Skip to content

Commit

Permalink
Try detecting clang::fallthrough using __has_cpp_attribute
Browse files Browse the repository at this point in the history
and use it to silence one of the warnings in #96.
  • Loading branch information
vitaut committed Feb 7, 2015
1 parent 83f5085 commit d7fea1b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion format.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
# define FMT_HAS_BUILTIN(x) 0
#endif

#ifdef __has_cpp_attribute
# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
#endif

#ifndef FMT_USE_VARIADIC_TEMPLATES
// Variadic templates are available in GCC since version 4.4
// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++
Expand Down Expand Up @@ -109,6 +115,12 @@
# define FMT_NOEXCEPT(expr)
#endif

#if FMT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define FMT_FALLTHROUGH [[clang::fallthrough]]
#else
# define FMT_FALLTHROUGH
#endif

// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
Expand Down Expand Up @@ -864,7 +876,7 @@ class ArgVisitor {
switch (arg.type) {
default:
assert(false);
// Fall through.
FMT_FALLTHROUGH;
case Arg::INT:
return FMT_DISPATCH(visit_int(arg.int_value));
case Arg::UINT:
Expand Down

0 comments on commit d7fea1b

Please sign in to comment.