Skip to content

Commit 1d3ad5a

Browse files
committed
Update print_dec usage for introduction of wi::to_wide
1 parent 82b6061 commit 1d3ad5a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

gcc-python-tree.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,13 +686,28 @@ PyGccConstructor_get_elements(PyObject *self, void *closure)
686686
return NULL;
687687
}
688688

689+
static void
690+
print_integer_cst_to_buf(tree int_cst, char *buf, tree type)
691+
{
692+
/*
693+
GCC 8 commit r253595 (aka e3d0f65c14ffd7a63455dc1aa9d0405d25b327e4,
694+
2017-10-10) introduces and requires the use of wi::to_wide on
695+
INTEGER_CST.
696+
*/
697+
#if (GCC_VERSION >= 8000)
698+
print_dec(wi::to_wide(int_cst), buf, TYPE_SIGN (type));
699+
#else
700+
print_dec(int_cst, buf, TYPE_SIGN (type));
701+
#endif
702+
}
703+
689704
PyObject *
690705
PyGcc_int_from_int_cst(tree int_cst)
691706
{
692707
tree type = TREE_TYPE(int_cst);
693708
#if (GCC_VERSION >= 5000)
694709
char buf[WIDE_INT_PRINT_BUFFER_SIZE];
695-
print_dec(int_cst, buf, TYPE_SIGN (type));
710+
print_integer_cst_to_buf (int_cst, buf, type);
696711
return PyGcc_int_from_decimal_string_buffer(buf);
697712
#else
698713
return PyGcc_int_from_double_int(TREE_INT_CST(int_cst),
@@ -712,7 +727,7 @@ PyGccIntegerConstant_repr(struct PyGccTree * self)
712727
tree type = TREE_TYPE(self->t.inner);
713728
#if (GCC_VERSION >= 5000)
714729
char buf[WIDE_INT_PRINT_BUFFER_SIZE];
715-
print_dec(self->t.inner, buf, TYPE_SIGN (type));
730+
print_integer_cst_to_buf (self->t.inner, buf, type);
716731
#else
717732
char buf[512];
718733
PyGcc_DoubleIntAsText(TREE_INT_CST(self->t.inner),

0 commit comments

Comments
 (0)