Commit 42aa1173 by Jakub Jelinek Committed by Jakub Jelinek

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
parent df8391b4
2016-11-28 Jakub Jelinek <jakub@redhat.com> 2016-11-28 Jakub Jelinek <jakub@redhat.com>
* 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 PR lto/78211
* ipa-icf.h (sem_item_optimizer): Add m_classes_vec member. * ipa-icf.h (sem_item_optimizer): Add m_classes_vec member.
* ipa-icf.c (sem_item_optimizer::sem_item_optimizer): Initialize * ipa-icf.c (sem_item_optimizer::sem_item_optimizer): Initialize
...@@ -733,23 +733,23 @@ format_percent (const conversion_spec &, tree) ...@@ -733,23 +733,23 @@ format_percent (const conversion_spec &, tree)
} }
/* Ugh. Compute intmax_type_node and uintmax_type_node the same way /* Compute intmax_type_node and uintmax_type_node similarly to how
lto/lto-lang.c does it. This should be available in tree.h. */ tree.c builds size_type_node. */
static void static void
build_intmax_type_nodes (tree *pintmax, tree *puintmax) 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; *pintmax = integer_type_node;
*puintmax = unsigned_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; *pintmax = long_integer_type_node;
*puintmax = long_unsigned_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; *pintmax = long_long_integer_type_node;
*puintmax = long_long_unsigned_type_node; *puintmax = long_long_unsigned_type_node;
...@@ -762,12 +762,14 @@ build_intmax_type_nodes (tree *pintmax, tree *puintmax) ...@@ -762,12 +762,14 @@ build_intmax_type_nodes (tree *pintmax, tree *puintmax)
char name[50]; char name[50];
sprintf (name, "__int%d unsigned", int_n_data[i].bitsize); 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; *pintmax = int_n_trees[i].signed_type;
*puintmax = int_n_trees[i].unsigned_type; *puintmax = int_n_trees[i].unsigned_type;
return;
} }
} }
gcc_unreachable ();
} }
} }
...@@ -851,15 +853,8 @@ format_pointer (const conversion_spec &spec, tree arg) ...@@ -851,15 +853,8 @@ format_pointer (const conversion_spec &spec, tree arg)
static fmtresult static fmtresult
format_integer (const conversion_spec &spec, tree arg) format_integer (const conversion_spec &spec, tree arg)
{ {
/* These are available as macros in the C and C++ front ends but, tree intmax_type_node;
sadly, not here. */ tree uintmax_type_node;
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);
/* Set WIDTH and PRECISION to either the values in the format /* Set WIDTH and PRECISION to either the values in the format
specification or to zero. */ specification or to zero. */
int width = spec.have_width ? spec.width : 0; int width = spec.have_width ? spec.width : 0;
...@@ -909,19 +904,20 @@ format_integer (const conversion_spec &spec, tree arg) ...@@ -909,19 +904,20 @@ format_integer (const conversion_spec &spec, tree arg)
break; break;
case FMT_LEN_z: case FMT_LEN_z:
dirtype = sign ? ptrdiff_type_node : size_type_node; dirtype = signed_or_unsigned_type_for (!sign, size_type_node);
break; break;
case FMT_LEN_t: case FMT_LEN_t:
dirtype = sign ? ptrdiff_type_node : size_type_node; dirtype = signed_or_unsigned_type_for (!sign, ptrdiff_type_node);
break; break;
case FMT_LEN_j: case FMT_LEN_j:
build_intmax_type_nodes (&intmax_type_node, &uintmax_type_node);
dirtype = sign ? intmax_type_node : uintmax_type_node; dirtype = sign ? intmax_type_node : uintmax_type_node;
break; break;
default: default:
return fmtresult (); return fmtresult ();
} }
/* The type of the argument to the directive, either deduced from /* The type of the argument to the directive, either deduced from
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment