aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.cc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-04-19 09:45:55 +0200
committerRichard Biener <rguenther@suse.de>2023-04-19 14:24:10 +0200
commit210617b53eee01d0a19117f886f5cf7717aa2319 (patch)
tree4d94933d5fac35d629b6f6e538334953617746bc /gcc/builtins.cc
parentfac24d43e68838c63bfe112c8fb63aa3df960429 (diff)
downloadgcc-210617b53eee01d0a19117f886f5cf7717aa2319.zip
gcc-210617b53eee01d0a19117f886f5cf7717aa2319.tar.gz
gcc-210617b53eee01d0a19117f886f5cf7717aa2319.tar.bz2
Transform more gmp/mpfr uses to use RAII
The following picks up the coccinelle generated patch from Bernhard, leaving out the fortran frontend parts and fixing up the rest. In particular both gmp.h and mpfr.h contain macros like #define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF) for which I add operator-> overloads to the auto_* classes. * system.h (auto_mpz::operator->()): New. * realmpfr.h (auto_mpfr::operator->()): New. * builtins.cc (do_mpfr_lgamma_r): Use auto_mpfr. * real.cc (real_from_string): Likewise. (dconst_e_ptr): Likewise. (dconst_sqrt2_ptr): Likewise. * tree-ssa-loop-niter.cc (refine_value_range_using_guard): Use auto_mpz. (bound_difference_of_offsetted_base): Likewise. (number_of_iterations_ne): Likewise. (number_of_iterations_lt_to_ne): Likewise. * ubsan.cc: Include realmpfr.h. (ubsan_instrument_float_cast): Use auto_mpfr.
Diffstat (limited to 'gcc/builtins.cc')
-rw-r--r--gcc/builtins.cc4
1 files changed, 1 insertions, 3 deletions
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 1bfdc59..80b8b89 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -11084,15 +11084,13 @@ do_mpfr_lgamma_r (tree arg, tree arg_sg, tree type)
const int prec = fmt->p;
const mpfr_rnd_t rnd = fmt->round_towards_zero? MPFR_RNDZ : MPFR_RNDN;
int inexact, sg;
- mpfr_t m;
tree result_lg;
- mpfr_init2 (m, prec);
+ auto_mpfr m (prec);
mpfr_from_real (m, ra, MPFR_RNDN);
mpfr_clear_flags ();
inexact = mpfr_lgamma (m, &sg, m, rnd);
result_lg = do_mpfr_ckconv (m, type, inexact);
- mpfr_clear (m);
if (result_lg)
{
tree result_sg;