From 87bdeeb591222b79a47fb3c41da75f4be069b293 Mon Sep 17 00:00:00 2001 From: "Yury V. Zaytsev" Date: Thu, 30 May 2024 19:26:07 +0200 Subject: [PATCH] buildsys: update ax_gcc_func_attribute to fix fallthrough detection Signed-off-by: Yury V. Zaytsev Signed-off-by: Andrew Borodin --- m4.include/ax_gcc_func_attribute.m4 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/m4.include/ax_gcc_func_attribute.m4 b/m4.include/ax_gcc_func_attribute.m4 index 098c9aadf..fa4e089d6 100644 --- a/m4.include/ax_gcc_func_attribute.m4 +++ b/m4.include/ax_gcc_func_attribute.m4 @@ -42,6 +42,7 @@ # flatten # format # format_arg +# gnu_format # gnu_inline # hot # ifunc @@ -77,7 +78,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 9 +#serial 13 AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) @@ -132,7 +133,7 @@ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ int foo( void ) __attribute__(($1)); ], [fallthrough], [ - int foo( void ) {switch (0) { case 1: __attribute__(($1)); case 2: break ; }}; + void foo( int x ) {switch (x) { case 1: __attribute__(($1)); case 2: break ; }}; ], [flatten], [ int foo( void ) __attribute__(($1)); @@ -140,6 +141,9 @@ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ [format], [ int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); ], + [gnu_format], [ + int foo(const char *p, ...) __attribute__((format(gnu_printf, 1, 2))); + ], [format_arg], [ char *foo(const char *p) __attribute__(($1(1))); ], @@ -224,7 +228,7 @@ AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ dnl GCC doesn't exit with an error if an unknown attribute is dnl provided but only outputs a warning, so accept the attribute dnl only if no warning were issued. - [AS_IF([test -s conftest.err], + [AS_IF([grep -- -Wattributes conftest.err], [AS_VAR_SET([ac_var], [no])], [AS_VAR_SET([ac_var], [yes])])], [AS_VAR_SET([ac_var], [no])])