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.
This commit is contained in:
parent
4b821c7efb
commit
3d654ca3f4
@ -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 ();
|
||||
}
|
||||
|
||||
|
16
gcc/testsuite/gcc.dg/analyzer/pr101875.c
Normal file
16
gcc/testsuite/gcc.dg/analyzer/pr101875.c
Normal file
@ -0,0 +1,16 @@
|
||||
char *
|
||||
fopen (const char *restrict, const char *restrict);
|
||||
|
||||
void
|
||||
err (void);
|
||||
|
||||
void
|
||||
k2 (void)
|
||||
{
|
||||
char *setfiles[1];
|
||||
int i;
|
||||
|
||||
setfiles[i] = fopen("", ""); /* { dg-warning "use of uninitialized value 'i'" } */
|
||||
if (!setfiles[i]) /* { dg-warning "use of uninitialized value 'i'" } */
|
||||
err ();
|
||||
} /* { dg-warning "leak of FILE" } */
|
Loading…
Reference in New Issue
Block a user