Add a FALL_THROUGH macro to compiler.h

Older gcc's don't support `__attribute__ ((fallthrough))`
(see https://sourceforge.net/u/begasus/tuxpaint/ci/e5c3cdfcf5e16a9b0fc3e7766bfea1d9c326b3ae/
"Haiku Fixes" by Luc), so adding a new macro to compiler.h
that is defined as "((void)0)" on older compilers.
This commit is contained in:
Bill Kendrick 2019-09-12 20:27:03 -07:00
parent e5c3cdfcf5
commit df49986fab
2 changed files with 21 additions and 12 deletions

View file

@ -5,7 +5,7 @@
for Tux Paint for Tux Paint
Mostly by Albert Cahalan <albert@users.sf.net> Mostly by Albert Cahalan <albert@users.sf.net>
Copyright (c) 2002-2006 Copyright (c) 2002-2019
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
@ -24,7 +24,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - December 30, 2017 June 14, 2002 - September 12, 2019
$Id$ $Id$
*/ */
@ -127,3 +127,13 @@
#undef CLOCK_ASM #undef CLOCK_ASM
#define CLOCK_ASM(x) x=42 #define CLOCK_ASM(x) x=42
#endif #endif
/* h/t https://tutel.me/c/programming/questions/45349079/how+to+use+__attribute__fallthrough+correctly+in+gcc */
#ifndef FALLTHROUGH
#if defined(__GNUC__) && __GNUC__ >= 7
#define FALL_THROUGH __attribute__ ((fallthrough))
#else
#define FALL_THROUGH ((void)0)
#endif /* __GNUC__ >= 7 */
#endif

View file

@ -45,7 +45,6 @@
#include "im.h" #include "im.h"
/* *************************************************************************** /* ***************************************************************************
* I18N GETTEXT * I18N GETTEXT
*/ */
@ -905,12 +904,12 @@ static int im_event_zh_tw(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
// // __attribute__ ((fallthrough)); /* go onto full reset */ FALL_THROUGH; /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
// __attribute__ ((fallthrough)); /* go onto soft reset */ FALL_THROUGH; /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1124,12 +1123,12 @@ static int im_event_th(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
// __attribute__ ((fallthrough)); /* go onto full reset */ FALL_THROUGH; /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
// __attribute__ ((fallthrough)); /* go onto soft reset */ FALL_THROUGH; /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1343,12 +1342,12 @@ static int im_event_ja(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
// __attribute__ ((fallthrough)); /* go onto full reset */ FALL_THROUGH; /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
// __attribute__ ((fallthrough)); /* go onto soft reset */ FALL_THROUGH; /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1590,12 +1589,12 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks)
case IM_REQ_FREE: /* Free allocated resources */ case IM_REQ_FREE: /* Free allocated resources */
charmap_free(&cm); charmap_free(&cm);
// __attribute__ ((fallthrough)); /* go onto full reset */ FALL_THROUGH; /* go onto full reset */
case IM_REQ_RESET_FULL: /* Full reset */ case IM_REQ_RESET_FULL: /* Full reset */
cm.section = SEC_ENGLISH; cm.section = SEC_ENGLISH;
im->tip_text = im_tip_text[IM_TIP_ENGLISH]; im->tip_text = im_tip_text[IM_TIP_ENGLISH];
// __attribute__ ((fallthrough)); /* go onto soft reset */ FALL_THROUGH; /* go onto soft reset */
case IM_REQ_RESET_SOFT: /* Soft reset */ case IM_REQ_RESET_SOFT: /* Soft reset */
im->s[0] = L'\0'; im->s[0] = L'\0';
@ -1681,7 +1680,7 @@ static int im_event_ko(IM_DATA * im, SDL_keysym ks)
im->redraw--; im->redraw--;
ks.unicode = L'\0'; ks.unicode = L'\0';
} }
// __attribute__ ((fallthrough)); /* continue processing: */ FALL_THROUGH; /* continue processing: */
/* Actual character processing */ /* Actual character processing */
default: default: