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’.
This commit is contained in:
Paul Eggert 2024-08-16 16:59:08 -07:00
parent 2169a9387a
commit cfa5a634e9

View file

@ -96,11 +96,6 @@ To add a new module function, proceed as follows:
#include <intprops.h>
#include <verify.h>
/* 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
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=21161>. */
{
int *volatile sign_volatile = sign;
sign = sign_volatile;
}
#endif
MODULE_FUNCTION_BEGIN (false);
Lisp_Object o = value_to_lisp (arg);
CHECK_INTEGER (o);