Skip to content

Commit

Permalink
Merge pull request #537 from skirpichev/fix-gcc-pedantic
Browse files Browse the repository at this point in the history
Fix -Wpedantic warnings from GCC
  • Loading branch information
casevh authored Dec 22, 2024
2 parents 1ccd629 + 1b58c54 commit 2329531
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 39 deletions.
5 changes: 3 additions & 2 deletions src/gmpy2.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,8 @@ PyMODINIT_FUNC PyInit_gmpy2(void)

#ifdef SHARED
/* Create the Capsule for the C-API. */

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
GMPy_C_API[MPZ_Type_NUM] = (void*)&MPZ_Type;
GMPy_C_API[XMPZ_Type_NUM] = (void*)&XMPZ_Type;
GMPy_C_API[MPQ_Type_NUM] = (void*)&MPQ_Type;
Expand Down Expand Up @@ -907,7 +908,7 @@ PyMODINIT_FUNC PyInit_gmpy2(void)
GMPy_C_API[GMPy_MPC_NewInit_NUM] = (void*)GMPy_MPC_NewInit;
GMPy_C_API[GMPy_MPC_Dealloc_NUM] = (void*)GMPy_MPC_Dealloc;
GMPy_C_API[GMPy_MPC_ConvertArg_NUM] = (void*)GMPy_MPC_ConvertArg;

#pragma GCC diagnostic pop
c_api_object = PyCapsule_New((void *)GMPy_C_API, "gmpy2._C_API", NULL);

if (c_api_object != NULL) {
Expand Down
34 changes: 17 additions & 17 deletions src/gmpy2_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ GMPy_CTXT_New(void)
result->token = NULL;
}
return (PyObject*)result;
};
}

static void
GMPy_CTXT_Dealloc(CTXT_Object *self)
{
PyObject_Free(self);
};
}

/* Begin support for context vars. */

Expand Down Expand Up @@ -654,7 +654,7 @@ static PyObject * \
GMPy_CTXT_Get_##NAME(CTXT_Object *self, void *closure) \
{ \
return PyBool_FromLong(self->ctx.NAME); \
}; \
} \
static int \
GMPy_CTXT_Set_##NAME(CTXT_Object *self, PyObject *value, void *closure) \
{ \
Expand All @@ -675,7 +675,7 @@ static PyObject * \
GMPy_CTXT_Get_##NAME(CTXT_Object *self, void *closure) \
{ \
return PyBool_FromLong(self->ctx.traps & TRAP); \
}; \
} \
static int \
GMPy_CTXT_Set_##NAME(CTXT_Object *self, PyObject *value, void *closure) \
{ \
Expand All @@ -690,19 +690,19 @@ GMPy_CTXT_Set_##NAME(CTXT_Object *self, PyObject *value, void *closure) \
return 0; \
}

GETSET_BOOLEAN(subnormalize);
GETSET_BOOLEAN(underflow);
GETSET_BOOLEAN(overflow);
GETSET_BOOLEAN(inexact);
GETSET_BOOLEAN(invalid);
GETSET_BOOLEAN(erange);
GETSET_BOOLEAN(divzero);
GETSET_BOOLEAN_BIT(trap_underflow, TRAP_UNDERFLOW);
GETSET_BOOLEAN_BIT(trap_overflow, TRAP_OVERFLOW);
GETSET_BOOLEAN_BIT(trap_inexact, TRAP_INEXACT);
GETSET_BOOLEAN_BIT(trap_invalid, TRAP_INVALID);
GETSET_BOOLEAN_BIT(trap_erange, TRAP_ERANGE);
GETSET_BOOLEAN_BIT(trap_divzero, TRAP_DIVZERO);
GETSET_BOOLEAN(subnormalize)
GETSET_BOOLEAN(underflow)
GETSET_BOOLEAN(overflow)
GETSET_BOOLEAN(inexact)
GETSET_BOOLEAN(invalid)
GETSET_BOOLEAN(erange)
GETSET_BOOLEAN(divzero)
GETSET_BOOLEAN_BIT(trap_underflow, TRAP_UNDERFLOW)
GETSET_BOOLEAN_BIT(trap_overflow, TRAP_OVERFLOW)
GETSET_BOOLEAN_BIT(trap_inexact, TRAP_INEXACT)
GETSET_BOOLEAN_BIT(trap_invalid, TRAP_INVALID)
GETSET_BOOLEAN_BIT(trap_erange, TRAP_ERANGE)
GETSET_BOOLEAN_BIT(trap_divzero, TRAP_DIVZERO)
GETSET_BOOLEAN(allow_complex)
GETSET_BOOLEAN(rational_division)
GETSET_BOOLEAN(allow_release_gil)
Expand Down
2 changes: 1 addition & 1 deletion src/gmpy2_convert_gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ _get_ieee_context(long bitwidth)
}
result->ctx.subnormalize = 1;
result->ctx.emin = 4 - result->ctx.emax - result->ctx.mpfr_prec;
return (PyObject*)result;
return result;
}

static PyObject *
Expand Down
8 changes: 4 additions & 4 deletions src/gmpy2_fused.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ PyDoc_STRVAR(GMPy_doc_function_fma,
"fma(x, y, z, /) -> mpz | mpq | mpfr | mpc\n\n"
"Return correctly rounded result of (x * y) + z.");

GMPY_MPFR_MPC_TRIOP_TEMPLATEWT(FMA, fma);
GMPY_MPFR_MPC_TRIOP_TEMPLATEWT(FMA, fma)

static PyObject *
_GMPy_MPZ_FMS(PyObject *x, PyObject *y, PyObject *z, CTXT_Object *context)
Expand Down Expand Up @@ -369,7 +369,7 @@ PyDoc_STRVAR(GMPy_doc_function_fms,
"fms(x, y, z, /) -> mpz | mpq | mpfr | mpc\n\n"
"Return correctly rounded result of (x * y) - z.");

GMPY_MPFR_MPC_TRIOP_TEMPLATEWT(FMS, fms);
GMPY_MPFR_MPC_TRIOP_TEMPLATEWT(FMS, fms)

/* Add support for new fmma and fmms functions from MPFR 4. */\

Expand Down Expand Up @@ -528,7 +528,7 @@ PyDoc_STRVAR(GMPy_doc_function_fmma,
"fmma(x, y, z, t, /) -> mpfr\n\n"
"Return correctly rounded result of (x * y) + (z + t).");

GMPY_MPFR_QUADOP_TEMPLATEWT(FMMA, fmma);
GMPY_MPFR_QUADOP_TEMPLATEWT(FMMA, fmma)

static PyObject *
_GMPy_MPZ_FMMS(PyObject *x, PyObject *y, PyObject *z, PyObject *t, CTXT_Object *context)
Expand Down Expand Up @@ -683,6 +683,6 @@ PyDoc_STRVAR(GMPy_doc_function_fmms,
"fmms(x, y, z, t, /) -> mpfr\n\n"
"Return correctly rounded result of (x * y) - (z + t).");

GMPY_MPFR_QUADOP_TEMPLATEWT(FMMS, fmms);
GMPY_MPFR_QUADOP_TEMPLATEWT(FMMS, fmms)

#endif
4 changes: 2 additions & 2 deletions src/gmpy2_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ PyDoc_STRVAR(GMPy_doc_context_floor,
"context.floor(x, /) -> mpfr\n\n"
"Return an `mpfr` that is the largest integer <= x.");

GMPY_MPFR_UNIOP_NOROUNDWT(Floor, floor);
GMPY_MPFR_UNIOP_NOROUNDWT(Floor, floor)

PyDoc_STRVAR(GMPy_doc_mpfr_trunc_method,
"x.__trunc__() -> mpfr\n\n"
Expand Down Expand Up @@ -1750,7 +1750,7 @@ GMPy_RealWithType_RemQuo(PyObject *x, int xtype, PyObject *y, int ytype, CTXT_Ob
return result;
}

GMPY_MPFR_BINOP_TEMPLATEWT(RemQuo, remquo);
GMPY_MPFR_BINOP_TEMPLATEWT(RemQuo, remquo)

PyDoc_STRVAR(GMPy_doc_function_frexp,
"frexp(x, /) -> tuple[int, mpfr]\n\n"
Expand Down
14 changes: 7 additions & 7 deletions src/gmpy2_predicate.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ GMPy_ComplexWithType_Is_NAN(PyObject *x, int xtype, CTXT_Object *context)
* GMPy_ComplexWithType_Is_NAN(x, xtype, context)
*/

GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_NAN, is_nan);
GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_NAN, is_nan)

PyDoc_STRVAR(GMPy_doc_function_is_infinite,
"is_infinite(x, /) -> bool\n\n"
Expand Down Expand Up @@ -156,7 +156,7 @@ GMPy_ComplexWithType_Is_Infinite(PyObject *x, int xtype, CTXT_Object *context)
Py_RETURN_FALSE;
}

GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_Infinite, is_infinite);
GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_Infinite, is_infinite)

PyDoc_STRVAR(GMPy_doc_function_is_finite,
"is_finite(x, /) -> bool\n\n"
Expand Down Expand Up @@ -217,7 +217,7 @@ GMPy_ComplexWithType_Is_Finite(PyObject *x, int xtype, CTXT_Object *context)
Py_RETURN_FALSE;
}

GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_Finite, is_finite);
GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_Finite, is_finite)

PyDoc_STRVAR(GMPy_doc_function_is_zero,
"is_zero(x, /) -> bool\n\n"
Expand Down Expand Up @@ -278,7 +278,7 @@ GMPy_ComplexWithType_Is_Zero(PyObject *x, int xtype, CTXT_Object *context)
Py_RETURN_FALSE;
}

GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_Zero, is_zero);
GMPY_MPFR_MPC_UNIOP_TEMPLATEWT(Is_Zero, is_zero)

PyDoc_STRVAR(GMPy_doc_function_is_signed,
"is_signed(x, /) -> bool\n\n"
Expand Down Expand Up @@ -323,7 +323,7 @@ GMPy_MPFR_Is_Signed_Method(PyObject *self, PyObject *args)
return GMPy_Number_Is_Signed(self, NULL);
}

GMPY_MPFR_UNIOP_TEMPLATEWT(Is_Signed, is_signed);
GMPY_MPFR_UNIOP_TEMPLATEWT(Is_Signed, is_signed)

PyDoc_STRVAR(GMPy_doc_function_is_regular,
"is_regular(x, /) -> bool\n\n"
Expand Down Expand Up @@ -368,7 +368,7 @@ GMPy_MPFR_Is_Regular_Method(PyObject *self, PyObject *args)
return GMPy_Number_Is_Regular(self, NULL);
}

GMPY_MPFR_UNIOP_TEMPLATEWT(Is_Regular, is_regular);
GMPY_MPFR_UNIOP_TEMPLATEWT(Is_Regular, is_regular)

PyDoc_STRVAR(GMPy_doc_function_is_integer,
"is_integer(x, /) -> bool\n\n"
Expand Down Expand Up @@ -413,7 +413,7 @@ GMPy_MPFR_Is_Integer_Method(PyObject *self, PyObject *args)
return GMPy_Number_Is_Integer(self, NULL);
}

GMPY_MPFR_UNIOP_TEMPLATEWT(Is_Integer, is_integer);
GMPY_MPFR_UNIOP_TEMPLATEWT(Is_Integer, is_integer)

PyDoc_STRVAR(GMPy_doc_function_is_lessgreater,
"is_lessgreater(x,y, /) -> bool\n\n"
Expand Down
6 changes: 3 additions & 3 deletions src/gmpy2_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ GMPy_RandomState_New(void)
gmp_randinit_default(result->state);
}
return result;
};
}

static void
GMPy_RandomState_Dealloc(RandomState_Object *self)
{
gmp_randclear(self->state);
PyObject_Free(self);
};
}

static PyObject *
GMPy_RandomState_Repr(RandomState_Object *self)
{
return PyUnicode_FromString("<gmpy2.RandomState>");
};
}

PyDoc_STRVAR(GMPy_doc_random_state_factory,
"random_state(seed=0, /) -> object\n\n"
Expand Down
6 changes: 3 additions & 3 deletions src/gmpy2_xmpz_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,14 @@ GMPy_Iter_New(void)
result->iter_type = 1;
}
return result;
};
}

static void
GMPy_Iter_Dealloc(GMPy_Iter_Object *self)
{
Py_XDECREF((PyObject*)self->bitmap);
PyObject_Free(self);
};
}

static PyObject *
GMPy_Iter_Next(GMPy_Iter_Object *self) {
Expand Down Expand Up @@ -399,7 +399,7 @@ static PyObject *
GMPy_Iter_Repr(GMPy_Iter_Object *self)
{
return PyUnicode_FromString("<gmpy2.Iterator>");
};
}

PyDoc_STRVAR(GMPy_doc_xmpz_method_iter_bits,
"x.iter_bits(start=0, stop=-1) -> collections.abc.Iterator\n\n"
Expand Down

0 comments on commit 2329531

Please sign in to comment.