aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/sm-file.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2021-08-23 14:11:58 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2021-08-23 14:11:58 -0400
commit3d654ca3f421ff9646470d312097602037176352 (patch)
tree0845568450bb3fac9750c45521759ab1d53921d3 /gcc/analyzer/sm-file.cc
parent4b821c7efbe12cfbb129a88541108b39058da526 (diff)
downloadgcc-3d654ca3f421ff9646470d312097602037176352.zip
gcc-3d654ca3f421ff9646470d312097602037176352.tar.gz
gcc-3d654ca3f421ff9646470d312097602037176352.tar.bz2
analyzer: fix ICE with NULL change.m_expr [PR101875]
gcc/analyzer/ChangeLog: PR analyzer/101875 * sm-file.cc (file_diagnostic::describe_state_change): Handle change.m_expr being NULL. gcc/testsuite/ChangeLog: PR analyzer/101875 * gcc.dg/analyzer/pr101875.c: New test.
Diffstat (limited to 'gcc/analyzer/sm-file.cc')
-rw-r--r--gcc/analyzer/sm-file.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc
index 6a17019..0c8cdf0 100644
--- a/gcc/analyzer/sm-file.cc
+++ b/gcc/analyzer/sm-file.cc
@@ -125,11 +125,21 @@ public:
return label_text::borrow ("opened here");
if (change.m_old_state == m_sm.m_unchecked
&& change.m_new_state == m_sm.m_nonnull)
- return change.formatted_print ("assuming %qE is non-NULL",
- change.m_expr);
+ {
+ if (change.m_expr)
+ return change.formatted_print ("assuming %qE is non-NULL",
+ change.m_expr);
+ else
+ return change.formatted_print ("assuming FILE * is non-NULL");
+ }
if (change.m_new_state == m_sm.m_null)
- return change.formatted_print ("assuming %qE is NULL",
- change.m_expr);
+ {
+ if (change.m_expr)
+ return change.formatted_print ("assuming %qE is NULL",
+ change.m_expr);
+ else
+ return change.formatted_print ("assuming FILE * is NULL");
+ }
return label_text ();
}