public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] avoid assuming SSA_NAME_IDENTIFIER is nonnull
@ 2021-01-17 22:37 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-01-17 22:37 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

More exhaustively testing the MEM_REF formatting change by
pretty-printing every MEM_REF the tree-ssa-uninit pass encounters
triggered another ICE, this one due to assuming SSA_NAME_IDENTIFIER
is non- null.  I have committed as "obvious" the attached patch to
remove the assumption after testing it on x86_64-linux.

Martin


[-- Attachment #2: gcc-ssa-name-null.diff --]
[-- Type: text/x-patch, Size: 2109 bytes --]

commit 192105b6a2a1f24f974de98c933f372b06c1e06d (HEAD -> master)
Author: Martin Sebor <msebor@redhat.com>
Date:   Sun Jan 17 15:27:08 2021 -0700

    Avoid assuming SSA_NAME_IDENTIFIER is nonnull.
    
    gcc/c-family/ChangeLog:
    
            * c-pretty-print.c (c_pretty_printer::primary_expression): Don't
            assume SSA_NAME_IDENTIFIER evaluates to nonzero.

diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 5a51c05fd75..2095d4badf7 100644
--- a/gcc/c-family/c-pretty-print.c
+++ b/gcc/c-family/c-pretty-print.c
@@ -1340,18 +1340,23 @@ c_pretty_printer::primary_expression (tree e)
       if (SSA_NAME_VAR (e))
        {
          tree var = SSA_NAME_VAR (e);
-         const char *name = IDENTIFIER_POINTER (SSA_NAME_IDENTIFIER (e));
-         const char *dot;
-         if (DECL_ARTIFICIAL (var) && (dot = strchr (name, '.')))
+         if (tree id = SSA_NAME_IDENTIFIER (e))
            {
-             /* Print the name without the . suffix (such as in VLAs).
-                Use pp_c_identifier so that it can be converted into
-                the appropriate encoding.  */
-             size_t size = dot - name;
-             char *ident = XALLOCAVEC (char, size + 1);
-             memcpy (ident, name, size);
-             ident[size] = '\0';
-             pp_c_identifier (this, ident);
+             const char *name = IDENTIFIER_POINTER (id);
+             const char *dot;
+             if (DECL_ARTIFICIAL (var) && (dot = strchr (name, '.')))
+               {
+                 /* Print the name without the . suffix (such as in VLAs).
+                    Use pp_c_identifier so that it can be converted into
+                    the appropriate encoding.  */
+                 size_t size = dot - name;
+                 char *ident = XALLOCAVEC (char, size + 1);
+                 memcpy (ident, name, size);
+                 ident[size] = '\0';
+                 pp_c_identifier (this, ident);
+               }
+             else
+               primary_expression (var);
            }
          else
            primary_expression (var);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-17 22:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17 22:37 [committed] avoid assuming SSA_NAME_IDENTIFIER is nonnull Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).