diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-04-16 08:11:02 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2019-04-16 08:11:02 +0000 |
commit | 05c5b20719a2b459fc191bf15d27b9b96457aff6 (patch) | |
tree | 10c4d855d81514f96db86c75b20dc3b64687e74e | |
parent | d0d12e55b5120dbe0a745e28332140f392362860 (diff) | |
download | mpfr-05c5b20719a2b459fc191bf15d27b9b96457aff6.tar.gz |
New macro MPFR_FALLTHROUGH to avoid -Wimplicit-fallthrough warnings
with GCC 7+. This macro also makes the code more readable by bringing
the attention on an unusual fallthrough in a switch case.
* src/mpfr-impl.h: define this macro.
* src/vasprintf.c: use this macro in a case of fallthrough.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13467 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/mpfr-impl.h | 9 | ||||
-rw-r--r-- | src/vasprintf.c | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index 2500fc554..30c29a81a 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -197,6 +197,15 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define MPFR_MAYBE_UNUSED #endif +/* This MPFR_FALLTHROUGH macro allows one to make fallthrough in switch case + explicit. Use this macro at the end of a switch case if it falls through, + in order to avoid a -Wimplicit-fallthrough warning. */ +#if __MPFR_GNUC(7,0) +#define MPFR_FALLTHROUGH __attribute__ ((fallthrough)) +#else +#define MPFR_FALLTHROUGH +#endif + /****************************************************** diff --git a/src/vasprintf.c b/src/vasprintf.c index 831452bbe..be7dd79c3 100644 --- a/src/vasprintf.c +++ b/src/vasprintf.c @@ -2167,6 +2167,7 @@ mpfr_vasnprintf_aux (char **ptr, char *Buf, size_t size, const char *fmt, break; case 'N': ++fmt; + MPFR_FALLTHROUGH; default: spec.rnd_mode = MPFR_RNDN; } |