------- Comment #5 from mmitchel at gcc dot gnu dot org 2005-10-31 06:25 ------- Kean, I think you need to check TREE_PUBLIC (decl) as well; a "static" main function isn't the main you're looking for. Note that a "static" main is permitted by gcc, with a warning, by default.
(It looks like the same bug appears in cfgexpand.c, by the way. I'll open a new PR for that.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24374