sanopt: Avoid crash on anonymous parameter [PR93436]
authorMarek Polacek <polacek@redhat.com>
Sun, 26 Jan 2020 00:02:11 +0000 (19:02 -0500)
committerMarek Polacek <polacek@redhat.com>
Sun, 26 Jan 2020 21:28:10 +0000 (16:28 -0500)
Here we crash when using -fsanitize=address -fdump-tree-sanopt because
the dumping code uses IDENTIFIER_POINTER on a null DECL_NAME.  Instead,
we can print "<anonymous>" in such a case.  Or we could avoid printing
that diagnostic altogether.

2020-01-26  Marek Polacek  <polacek@redhat.com>

PR tree-optimization/93436
* sanopt.c (sanitize_rewrite_addressable_params): Avoid crash on
null DECL_NAME.

gcc/ChangeLog
gcc/sanopt.c

index e983d5233b1c3efdfa089c4f5db5edd6646ac59e..8f6f4ae7b80bbae468885d15f560c87457acb682 100644 (file)
@@ -1,3 +1,9 @@
+2020-01-26  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/93436
+       * sanopt.c (sanitize_rewrite_addressable_params): Avoid crash on
+       null DECL_NAME.
+
 2020-01-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/92601
index 619aae45a15e360a57ce24e13b63bcc0d6da872d..0788eef597ee8bc4c6a2760d40b9839a106a53ed 100644 (file)
@@ -1174,9 +1174,12 @@ sanitize_rewrite_addressable_params (function *fun)
            continue;
 
          if (dump_file)
-           fprintf (dump_file,
-                    "Rewriting parameter whose address is taken: %s\n",
-                    IDENTIFIER_POINTER (DECL_NAME (arg)));
+           {
+             fprintf (dump_file,
+                      "Rewriting parameter whose address is taken: ");
+             print_generic_expr (dump_file, arg, dump_flags);
+             fputc ('\n', dump_file);
+           }
 
          SET_DECL_PT_UID (var, DECL_PT_UID (arg));