summaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-sprintf.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-28 10:01:30 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-28 10:01:30 +0000
commit6156f076311221055bd672788acb3180ac624258 (patch)
tree26baba16e6a79b82eaec8b17b88da22d38bb2964 /gcc/gimple-ssa-sprintf.c
parent72fbc3e1f5b43fd28a08dabd12ba41584d1d33d4 (diff)
downloadgcc-6156f076311221055bd672788acb3180ac624258.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242911 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r--gcc/gimple-ssa-sprintf.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index dc2b66d3430..71014ebcb6c 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