+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.
+
2020-03-05 Richard Biener <rguenther@suse.de>
Jakub Jelinek <jakub@redhat.com>
pp_string (pp, tmp);
break;
case CONST_STRING:
- pp_printf (pp, "\"%s\"", XSTR (x, 0));
+ pp_string (pp, "\"");
+ pretty_print_string (pp, XSTR (x, 0), strlen (XSTR (x, 0)));
+ pp_string (pp, "\"");
break;
case SYMBOL_REF:
pp_printf (pp, "`%s'", XSTR (x, 0));
2020-03-05 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/93399
+ * gcc.dg/pr93399.c: New test.
+
PR tree-optimization/93582
* gcc.dg/tree-ssa/pr93582-11.c: New test.
--- /dev/null
+/* PR middle-end/93399 */
+/* { dg-do assemble } */
+/* { dg-options "-fverbose-asm -dA -g -O3" } */
+
+extern inline __attribute__ ((__always_inline__, __gnu_inline__)) char *
+strstr (const char *haystack, const char *needle)
+{
+ return __builtin_strstr (haystack, needle);
+}
+
+int
+main (int argc, const char **argv)
+{
+ char *substr = strstr (argv[0], "\n");
+ char *another = strstr (argv[0], "\r\n");
+ return 0;
+}
/* 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);
/* 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;
extern int op_code_prio (enum tree_code);
extern int op_prio (const_tree);
extern const char *op_symbol_code (enum tree_code);
+extern void pretty_print_string (pretty_printer *, const char *, size_t);
extern void print_call_name (pretty_printer *, tree, dump_flags_t);
extern void percent_K_format (text_info *, location_t, tree);
extern void pp_tree_identifier (pretty_printer *, tree);