diff options
author | David Malcolm <dmalcolm@redhat.com> | 2021-08-23 14:11:58 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2021-08-23 14:11:58 -0400 |
commit | 3d654ca3f421ff9646470d312097602037176352 (patch) | |
tree | 0845568450bb3fac9750c45521759ab1d53921d3 /gcc/analyzer/sm-file.cc | |
parent | 4b821c7efbe12cfbb129a88541108b39058da526 (diff) | |
download | gcc-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.cc | 18 |
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 (); } |