------- Comment #4 from burnus at gcc dot gnu dot org 2009-05-27 14:26 ------- Thanks for reporting it. I don't quite understand why I did not see it. Anyhow, for
PROGRAM TEST END PROGRAM TEST one gets the dump: test () { (void) 0; } main (integer(kind=4) argc, character(kind=1) * * argv) { static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1}; _gfortran_set_args (argc, argv); _gfortran_set_options (8, &options.0[0]); test (); return 0; } Which looks OK. But with "-Wall -O" one gets the warning: 'test' defined but not used I don't see ad hoc why "test();" is not enough to be regarded as "used", but writing TREE directly probably means that one has to do everything manually. How about the following patch: Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 147906) +++ gcc/fortran/trans-decl.c (working copy) @@ -4000,6 +4001,9 @@ create_main_function (tree fndecl) tmp = build_call_expr (fndecl, 0); gfc_add_expr_to_block (&body, tmp); + /* Mark MAIN__ as used. */ + TREE_USED (fndecl) = 1; + /* "return 0". */ tmp = fold_build2 (MODIFY_EXPR, integer_type_node, DECL_RESULT (ftn_main), build_int_cst (integer_type_node, 0)); -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2009-05-27 14:26:29 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40270