aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-pretty-print.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-03-05 09:12:44 +0100
committerJakub Jelinek <jakub@redhat.com>2020-03-05 09:12:44 +0100
commitfebfe87d80c5bc8afd9038136ae7c09910a0d883 (patch)
tree566935b3278662e79e7f1734be2771b92e29f48b /gcc/tree-pretty-print.c
parentc9f90a25d4945e904839326957c7c4d34abd88dd (diff)
downloadgcc-febfe87d80c5bc8afd9038136ae7c09910a0d883.zip
gcc-febfe87d80c5bc8afd9038136ae7c09910a0d883.tar.gz
gcc-febfe87d80c5bc8afd9038136ae7c09910a0d883.tar.bz2
print-rtl: Fix printing of CONST_STRING in DEBUG_INSNs [PR93399]
The following testcase fails to assemble, as CONST_STRING in the DEBUG_INSNs is printed as is, so if it contains \n and/or \r, we are in trouble: .loc 1 14 3 # DEBUG haystack => [si] # DEBUG needle => " " In the gimple dumps we print those (STRING_CSTs) as # DEBUG haystack => D#1 # DEBUG needle => "\n" so this patch uses what we use in tree printing for the CONST_STRINGs too. 2020-03-05 Jakub Jelinek <jakub@redhat.com> PR middle-end/93399 * tree-pretty-print.h (pretty_print_string): Declare. * tree-pretty-print.c (pretty_print_string): Remove forward declaration, no longer static. Change nbytes parameter type from unsigned to size_t. * print-rtl.c (print_value) <case CONST_STRING>: Use pretty_print_string and for shrink way too long strings. * gcc.dg/pr93399.c: New test.
Diffstat (limited to 'gcc/tree-pretty-print.c')
-rw-r--r--gcc/tree-pretty-print.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 7de8c7b..885ca8c 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -45,7 +45,6 @@ along with GCC; see the file COPYING3. If not see
/* Local functions, macros and variables. */
static const char *op_symbol (const_tree);
-static void pretty_print_string (pretty_printer *, const char*, unsigned);
static void newline_and_indent (pretty_printer *, int);
static void maybe_init_pretty_print (FILE *);
static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
@@ -4216,8 +4215,8 @@ print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
/* Print the first N characters in the array STR, replacing non-printable
characters (including embedded nuls) with unambiguous escape sequences. */
-static void
-pretty_print_string (pretty_printer *pp, const char *str, unsigned n)
+void
+pretty_print_string (pretty_printer *pp, const char *str, size_t n)
{
if (str == NULL)
return;