aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-01-17 15:27:08 -0700
committerMartin Sebor <msebor@redhat.com>2021-01-17 15:27:08 -0700
commit192105b6a2a1f24f974de98c933f372b06c1e06d (patch)
treeb1cf8ebe341926e5085e532cde20bb72a601f486
parent0f4c8f517b7954e113afb4d5c7212123c8ee2418 (diff)
downloadgcc-192105b6a2a1f24f974de98c933f372b06c1e06d.zip
gcc-192105b6a2a1f24f974de98c933f372b06c1e06d.tar.gz
gcc-192105b6a2a1f24f974de98c933f372b06c1e06d.tar.bz2
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.
-rw-r--r--gcc/c-family/c-pretty-print.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c
index 5a51c05..2095d4b 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);