analyzer: fix ICE on 'bind(INT_CST, ...)' [PR107783]

This was crashing inside fd_phase_mismatch's ctor with assertion
failure when the state was "fd-constant".

Fix the ICE by not complaining about constants passed to these APIs.

	PR analyzer/107783
	* (fd_state_machine::check_for_new_socket_fd): Don't
	complain when old state is "fd-constant".
	(fd_state_machine::on_listen): Likewise.
	(fd_state_machine::on_accept): Likewise.

	PR analyzer/107783
	* gcc.dg/analyzer/fd-accept.c (test_accept_on_constant): New.
	* gcc.dg/analyzer/fd-bind.c (test_bind_on_constant): New.
	* gcc.dg/analyzer/fd-connect.c (test_connect_on_constant): New.
	* gcc.dg/analyzer/fd-listen.c (test_listen_on_connected_socket):
	Fix typo.
	(test_listen_on_constant): New.

Signed-off-by: David Malcolm <>
5 files changed