From f568ee8b70b45f80afb2de8d3edf98a99e00f9cd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 16 Aug 2024 16:59:08 -0700 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20ignore=20-Wclobbered=20in=20emac?= =?utf8?q?s-module.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fix is also prompted by Emacs bug#71744. * src/emacs-module.c: Do not ignore -Wclobbered. (MODULE_HANDLE_NONLOCAL_EXIT): Fix violations of the C standard, where setjmp clobbered env and internal_cleanup. (module_extract_big_integer) [GCC_LINT && __GNUC__ && !__clang__]: Work around GCC -Wclobbered false positive for ‘sign’. (cherry picked from commit cfa5a634e91f5c232a71ec212679165074dc480b) --- src/emacs-module.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/emacs-module.c b/src/emacs-module.c index 05aa0baef74..5aa4cfa0ae8 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -96,11 +96,6 @@ To add a new module function, proceed as follows: #include #include -/* Work around GCC bug 83162. */ -#if GNUC_PREREQ (4, 3, 0) -# pragma GCC diagnostic ignored "-Wclobbered" -#endif - /* We use different strategies for allocating the user-visible objects (struct emacs_runtime, emacs_env, emacs_value), depending on whether the user supplied the -module-assertions flag. If @@ -273,14 +268,17 @@ module_decode_utf_8 (const char *str, ptrdiff_t len) module_out_of_memory (env); \ return retval; \ } \ - struct handler *internal_cleanup \ + emacs_env *env_volatile = env; \ + struct handler *volatile internal_cleanup \ = internal_handler; \ - if (sys_setjmp (internal_cleanup->jmp)) \ + if (sys_setjmp (internal_handler->jmp)) \ { \ + emacs_env *env = env_volatile; \ + struct handler *internal_handler = internal_cleanup; \ module_handle_nonlocal_exit (env, \ - internal_cleanup->nonlocal_exit, \ - internal_cleanup->val); \ - module_reset_handlerlist (internal_cleanup); \ + internal_handler->nonlocal_exit, \ + internal_handler->val); \ + module_reset_handlerlist (internal_handler); \ return retval; \ } \ do { } while (false) @@ -1045,6 +1043,15 @@ static bool module_extract_big_integer (emacs_env *env, emacs_value arg, int *sign, ptrdiff_t *count, emacs_limb_t *magnitude) { +#if GCC_LINT && __GNUC__ && !__clang__ + /* These useless assignments pacify GCC 14.2.1 x86-64 + . */ + { + int *volatile sign_volatile = sign; + sign = sign_volatile; + } +#endif + MODULE_FUNCTION_BEGIN (false); Lisp_Object o = value_to_lisp (arg); CHECK_INTEGER (o); -- 2.39.2