mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
compiler: Add fallthrough() helper
https://bugzilla.nasm.us/show_bug.cgi?id=3392465 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
26
aclocal.m4
vendored
26
aclocal.m4
vendored
@@ -199,3 +199,29 @@ inline int foo(int x)
|
|||||||
[Define to 1 if your compiler supports C99 extern inline])],
|
[Define to 1 if your compiler supports C99 extern inline])],
|
||||||
[AC_MSG_RESULT([no])
|
[AC_MSG_RESULT([no])
|
||||||
PA_ADD_CFLAGS([-fgnu89-inline])])])
|
PA_ADD_CFLAGS([-fgnu89-inline])])])
|
||||||
|
|
||||||
|
dnl --------------------------------------------------------------------------
|
||||||
|
dnl PA_CHECK_FALLTHROUGH_ATTRIBUTE
|
||||||
|
dnl --------------------------------------------------------------------------
|
||||||
|
AC_DEFUN(PA_CHECK_FALLTHROUGH_ATTRIBUTE,
|
||||||
|
[AC_MSG_CHECKING([if $CC supports fallthrough attribute])
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||||
|
AC_INCLUDES_DEFAULT
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
switch (argc) {
|
||||||
|
case 1:
|
||||||
|
(void)argc;
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
default:
|
||||||
|
(void)argv;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return argc;
|
||||||
|
}
|
||||||
|
])],
|
||||||
|
[AC_MSG_RESULT([yes])
|
||||||
|
AC_DEFINE([HAVE_FALLTHROUGH_ATTRIBUTE], 1,
|
||||||
|
[Define to 1 if your compiler supports __attribute__((fallthrough))])],
|
||||||
|
[AC_MSG_RESULT([no])])
|
||||||
|
])
|
||||||
|
@@ -294,6 +294,11 @@ dnl options.
|
|||||||
dnl
|
dnl
|
||||||
PA_CHECK_BAD_STDC_INLINE
|
PA_CHECK_BAD_STDC_INLINE
|
||||||
|
|
||||||
|
dnl Figure out if we can use fallthrough attribute or
|
||||||
|
dnl should provide simple comment instead.
|
||||||
|
dnl
|
||||||
|
PA_CHECK_FALLTHROUGH_ATTRIBUTE
|
||||||
|
|
||||||
dnl
|
dnl
|
||||||
dnl support ccache
|
dnl support ccache
|
||||||
dnl
|
dnl
|
||||||
|
@@ -240,6 +240,15 @@ size_t strnlen(const char *s, size_t maxlen);
|
|||||||
# define inline_prototypes
|
# define inline_prototypes
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fallthrough handling.
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_FALLTHROUGH_ATTRIBUTE
|
||||||
|
# define fallthrough() __attribute__((fallthrough))
|
||||||
|
#else
|
||||||
|
# define fallthrough() /* fall through */
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hints to the compiler that a particular branch of code is more or
|
* Hints to the compiler that a particular branch of code is more or
|
||||||
* less likely to be taken.
|
* less likely to be taken.
|
||||||
|
Reference in New Issue
Block a user