gcc/analyzer/ChangeLog:
PR analyzer/96644
* region-model-manager.cc (get_region_for_unexpected_tree_code):
Handle ctxt being NULL.
gcc/testsuite/ChangeLog:
PR analyzer/96644
* gcc.dg/analyzer/pr96644.c: New test.
tree t,
const dump_location_t &loc)
{
- gcc_assert (ctxt);
tree type = TYPE_P (t) ? t : TREE_TYPE (t);
region *new_reg
= new unknown_region (alloc_region_id (), &m_root_region, type);
- ctxt->on_unexpected_tree_code (t, loc);
+ if (ctxt)
+ ctxt->on_unexpected_tree_code (t, loc);
return new_reg;
}
--- /dev/null
+/* { dg-additional-options "-O1" } */
+
+int oh[1];
+int *x3;
+
+int *
+cm (char *m0)
+{
+ return oh;
+}
+
+void
+ek (void)
+{
+ for (;;)
+ {
+ char *b2 = 0;
+
+ if (*b2 != 0) /* { dg-warning "dereference of NULL" } */
+ ++b2;
+
+ x3 = cm (b2);
+ }
+}