program-state.cc
37 KB
-
analyzer: fix global-sm-state issue affecting sm-signal · 7fb3669e
sm-signal.cc was failing to warn about the use of an fprintf call in a signal handler when the signal handler function was non-static. The root cause was a failure to copy global sm-state within sm_state_map::clone_with_remapping as called by program_state::can_merge_with_p, which led to the exploded node for the entrypoint to the handler in the "normal" state being erroneously reused for the "in_signal_handler" state, thus losing the global state, and thus failing to warn. This patch fixes the above, so that non-equal global sm-state values prevent merger of program_state, thus requiring separate exploded nodes for the "normal" and "in signal handler" states, and thus triggering the warning for the reproducer. gcc/analyzer/ChangeLog: * program-state.cc (sm_state_map::clone_with_remapping): Copy m_global_state. (selftest::test_program_state_merging_2): New selftest. (selftest::analyzer_program_state_cc_tests): Call it. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/signal-6.c: New test.
David Malcolm committed