mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-02 14:30:10 +00:00
Merge pull request #101 from cppformat/fallthrough
Try detecting clang::fallthrough using __has_cpp_attribute
This commit is contained in:
commit
fe2b5351be
14
format.h
14
format.h
@ -80,6 +80,12 @@
|
|||||||
# define FMT_HAS_BUILTIN(x) 0
|
# define FMT_HAS_BUILTIN(x) 0
|
||||||
#endif
|
#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
|
#ifndef FMT_USE_VARIADIC_TEMPLATES
|
||||||
// Variadic templates are available in GCC since version 4.4
|
// Variadic templates are available in GCC since version 4.4
|
||||||
// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++
|
// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++
|
||||||
@ -113,6 +119,12 @@
|
|||||||
# define FMT_NOEXCEPT(expr)
|
# define FMT_NOEXCEPT(expr)
|
||||||
#endif
|
#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
|
// A macro to disallow the copy constructor and operator= functions
|
||||||
// This should be used in the private: declarations for a class
|
// This should be used in the private: declarations for a class
|
||||||
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
@ -868,7 +880,7 @@ class ArgVisitor {
|
|||||||
switch (arg.type) {
|
switch (arg.type) {
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
// Fall through.
|
FMT_FALLTHROUGH;
|
||||||
case Arg::INT:
|
case Arg::INT:
|
||||||
return FMT_DISPATCH(visit_int(arg.int_value));
|
return FMT_DISPATCH(visit_int(arg.int_value));
|
||||||
case Arg::UINT:
|
case Arg::UINT:
|
||||||
|
Loading…
Reference in New Issue
Block a user