I'd probably cower in fear first

, then maybe go talk to the kid after the guy left. Help the kid and his parents report that guy for threatening physical harm.
I'd in no way have the balls to talk to the guy. If he's yelling at a 5 year old, he's not going to stand to reason with an adult in that state.
Hitting him is sending the wrong message to the kid, so that's a big no, as far as I see it.
I'd also be hesitant to call the police since I'd feel like I didn't know enough about the whole situation to be able to report it accurately.