namespace diagnostics {
/* Compute the number of digits in the decimal representation of an integer. */
-extern int num_digits (int);
+extern int num_digits (uint64_t);
} // namespace diagnostics
/* Get the number of digits in the decimal representation of VALUE. */
int
-num_digits (int value)
+num_digits (uint64_t value)
{
/* Perhaps simpler to use log10 for this, but doing it this way avoids
using floating point. */
- gcc_assert (value >= 0);
if (value == 0)
return 1;
ASSERT_EQ (7, num_digits (9999999));
ASSERT_EQ (8, num_digits (10000000));
ASSERT_EQ (8, num_digits (99999999));
+ ASSERT_EQ (20, num_digits (uint64_t (-1)));
}
/* Run all of the selftests within this file.
static void
write_digit (FILE *stream, int digit)
{
- fputc ('0' + (digit % 10), stream);
+ fputc ('0' + digit, stream);
}
/* Helper function for dump_location_info.
for (int column = 1; column < max_col; column++)
{
location_t column_loc = loc + (location_t (column) << map->m_range_bits);
- write_digit (stream, column_loc / divisor);
+ write_digit (stream, (column_loc / divisor) % 10);
}
fprintf (stream, "\n");
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fplugin-arg-location_overflow_plugin-value=1024 -fdump-internal-locations" } */
+
+/* The plugin arranges for location_t values to exceed 32 bits; verify the
+ internal dump routines don't crash. The exact output depends on the system
+ and on absolute path names, and this output is only meant for internal
+ purposes, so don't demand an exact form of the output. */
+
+/* { dg-allow-blank-lines-in-output 1 } */
+/* { dg-prune-output ".*" } */
{ location_overflow_plugin.cc \
location-overflow-test-1.c \
location-overflow-test-2.c \
+ location-overflow-test-3.c \
location-overflow-test-pr83173.c \
location-overflow-test-pr116047.c \
location-overflow-test-pr120061.c } \