From: Paul Eggert Date: Fri, 16 Aug 2024 23:59:08 +0000 (-0700) Subject: Don’t ignore -Wclobbered in emacs-module.c X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f568ee8b70b45f80afb2de8d3edf98a99e00f9cd;p=emacs.git Don’t ignore -Wclobbered in emacs-module.c 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) --- 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);