From 42aa1173f256069d5933b9a3ed4a8c5c99871ca7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 28 Nov 2016 11:01:30 +0100 Subject: [PATCH] gimple-ssa-sprintf.c (build_intmax_type_nodes): Look at UINTMAX_TYPE rather than SIZE_TYPE. * gimple-ssa-sprintf.c (build_intmax_type_nodes): Look at UINTMAX_TYPE rather than SIZE_TYPE. Add gcc_unreachable if intmax_t couldn't be determined. (format_integer): Make {,u}intmax_type_node no longer static, initialize them only when needed. For z and t use signed_or_unsigned_type_for instead of assuming size_t and ptrdiff_t have the same precision. From-SVN: r242911 --- gcc/ChangeLog | 8 ++++++++ gcc/gimple-ssa-sprintf.c | 32 ++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9d1b81d..73c23fc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2016-11-28 Jakub Jelinek + * gimple-ssa-sprintf.c (build_intmax_type_nodes): Look at + UINTMAX_TYPE rather than SIZE_TYPE. Add gcc_unreachable if + intmax_t couldn't be determined. + (format_integer): Make {,u}intmax_type_node no longer static, + initialize them only when needed. For z and t use + signed_or_unsigned_type_for instead of assuming size_t and + ptrdiff_t have the same precision. + PR lto/78211 * ipa-icf.h (sem_item_optimizer): Add m_classes_vec member. * ipa-icf.c (sem_item_optimizer::sem_item_optimizer): Initialize diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index dc2b66d..71014eb 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -733,23 +733,23 @@ format_percent (const conversion_spec &, tree) } -/* Ugh. Compute intmax_type_node and uintmax_type_node the same way - lto/lto-lang.c does it. This should be available in tree.h. */ +/* Compute intmax_type_node and uintmax_type_node similarly to how + tree.c builds size_type_node. */ static void build_intmax_type_nodes (tree *pintmax, tree *puintmax) { - if (strcmp (SIZE_TYPE, "unsigned int") == 0) + if (strcmp (UINTMAX_TYPE, "unsigned int") == 0) { *pintmax = integer_type_node; *puintmax = unsigned_type_node; } - else if (strcmp (SIZE_TYPE, "long unsigned int") == 0) + else if (strcmp (UINTMAX_TYPE, "long unsigned int") == 0) { *pintmax = long_integer_type_node; *puintmax = long_unsigned_type_node; } - else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0) + else if (strcmp (UINTMAX_TYPE, "long long unsigned int") == 0) { *pintmax = long_long_integer_type_node; *puintmax = long_long_unsigned_type_node; @@ -762,12 +762,14 @@ build_intmax_type_nodes (tree *pintmax, tree *puintmax) char name[50]; sprintf (name, "__int%d unsigned", int_n_data[i].bitsize); - if (strcmp (name, SIZE_TYPE) == 0) + if (strcmp (name, UINTMAX_TYPE) == 0) { *pintmax = int_n_trees[i].signed_type; *puintmax = int_n_trees[i].unsigned_type; + return; } } + gcc_unreachable (); } } @@ -851,15 +853,8 @@ format_pointer (const conversion_spec &spec, tree arg) static fmtresult format_integer (const conversion_spec &spec, tree arg) { - /* These are available as macros in the C and C++ front ends but, - sadly, not here. */ - static tree intmax_type_node; - static tree uintmax_type_node; - - /* Initialize the intmax nodes above the first time through here. */ - if (!intmax_type_node) - build_intmax_type_nodes (&intmax_type_node, &uintmax_type_node); - + tree intmax_type_node; + tree uintmax_type_node; /* Set WIDTH and PRECISION to either the values in the format specification or to zero. */ int width = spec.have_width ? spec.width : 0; @@ -909,19 +904,20 @@ format_integer (const conversion_spec &spec, tree arg) break; case FMT_LEN_z: - dirtype = sign ? ptrdiff_type_node : size_type_node; + dirtype = signed_or_unsigned_type_for (!sign, size_type_node); break; case FMT_LEN_t: - dirtype = sign ? ptrdiff_type_node : size_type_node; + dirtype = signed_or_unsigned_type_for (!sign, ptrdiff_type_node); break; case FMT_LEN_j: + build_intmax_type_nodes (&intmax_type_node, &uintmax_type_node); dirtype = sign ? intmax_type_node : uintmax_type_node; break; default: - return fmtresult (); + return fmtresult (); } /* The type of the argument to the directive, either deduced from -- 2.7.4