Mercurial > hg > CbC > CbC_gcc
diff gcc/fortran/misc.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/gcc/fortran/misc.c Fri Oct 27 22:46:09 2017 +0900 +++ b/gcc/fortran/misc.c Thu Oct 25 07:37:49 2018 +0900 @@ -1,5 +1,5 @@ /* Miscellaneous stuff that doesn't fit anywhere else. - Copyright (C) 2000-2017 Free Software Foundation, Inc. + Copyright (C) 2000-2018 Free Software Foundation, Inc. Contributed by Andy Vaught This file is part of GCC. @@ -23,6 +23,7 @@ #include "coretypes.h" #include "gfortran.h" #include "spellcheck.h" +#include "tree.h" /* Initialize a typespec to unknown. */ @@ -155,7 +156,8 @@ sprintf (buffer, "TYPE(%s)", ts->u.derived->name); break; case BT_CLASS: - ts = &ts->u.derived->components->ts; + if (ts->u.derived->components) + ts = &ts->u.derived->components->ts; if (ts->u.derived->attr.unlimited_polymorphic) sprintf (buffer, "CLASS(*)"); else @@ -284,7 +286,7 @@ /* For a given name TYPO, determine the best candidate from CANDIDATES - perusing Levenshtein distance. Frees CANDIDATES before returning. */ + using get_edit_distance. Frees CANDIDATES before returning. */ const char * gfc_closest_fuzzy_match (const char *typo, char **candidates) @@ -297,7 +299,7 @@ while (cand && *cand) { - edit_distance_t dist = levenshtein_distance (typo, tl, *cand, + edit_distance_t dist = get_edit_distance (typo, tl, *cand, strlen (*cand)); if (dist < best_distance) { @@ -321,3 +323,23 @@ } return best; } + +/* Convert between GMP integers (mpz_t) and HOST_WIDE_INT. */ + +HOST_WIDE_INT +gfc_mpz_get_hwi (mpz_t op) +{ + /* Using long_long_integer_type_node as that is the integer type + node that closest matches HOST_WIDE_INT; both are guaranteed to + be at least 64 bits. */ + const wide_int w = wi::from_mpz (long_long_integer_type_node, op, true); + return w.to_shwi (); +} + + +void +gfc_mpz_set_hwi (mpz_t rop, const HOST_WIDE_INT op) +{ + const wide_int w = wi::shwi (op, HOST_BITS_PER_WIDE_INT); + wi::to_mpz (w, rop, SIGNED); +}