introduce SPOT_FALLTHROUGH to cope with -Wimplicit-fallthrough

* NEWS: Mention the fix.
* HACKING: Mention the new macro.
* spot/misc/common.hh (SPOT_FALLTHROUGH): Add the macro.
* bin/randltl.cc, spot/misc/escape.cc, spot/tl/mutation.cc,
spot/tl/print.cc, spot/tl/simplify.hh, spot/tl/snf.cc, spot/twa/acc.cc,
spot/twaalgos/ltl2taa.cc, spot/twaalgos/ltl2tgba_fm.cc,
spot/twaalgos/sepsets.cc, spot/twaalgos/translate.cc: Use it.
This commit is contained in:
Alexandre Duret-Lutz 2016-10-07 17:25:09 +02:00
parent fa80571d44
commit a5d6aa2533
14 changed files with 85 additions and 27 deletions

View file

@ -117,6 +117,20 @@
// auto func(int param) SPOT_RETURN(implem_.func(param));
#define SPOT_RETURN(code) -> decltype(code) { return code; }
// We hope compilers that implement -Wimplicit-fallthrough
// also support __has_cpp_attribute and some form of [[fallthrough]].
#ifdef __has_cpp_attribute
# if __has_cpp_attribute(fallthrough)
# define SPOT_FALLTHROUGH [[fallthrough]]
# elif __has_cpp_attribute(clang::fallthrough)
# define SPOT_FALLTHROUGH [[clang::fallthrough]]
# elif __has_cpp_attribute(gcc::fallthrough)
# define SPOT_FALLTHROUGH [[gcc::fallthrough]]
# endif
#endif
#ifndef SPOT_FALLTHROUGH
# define SPOT_FALLTHROUGH while (0)
#endif
namespace spot
{