c-decl.c (finish_function): Don't treat 'main' specially unless flag_hosted.
authorJoseph Myers <jsm28@cam.ac.uk>
Thu, 27 Jul 2000 19:51:41 +0000 (13:51 -0600)
committerJeff Law <law@gcc.gnu.org>
Thu, 27 Jul 2000 19:51:41 +0000 (13:51 -0600)
* c-decl.c (finish_function): Don't treat 'main' specially unless
flag_hosted.  In C99 mode, return 0 from 'main' unless
DEFAULT_MAIN_RETURN is otherwise defined.

From-SVN: r35300

gcc/ChangeLog
gcc/c-decl.c

index 0cc077e72d6aafaff464c718048d6a0c5abbfb50..6cc96ac547e9b1d5339ed76b8f6473c1ae5150d1 100644 (file)
 
 2000-07-27  Joseph S. Myers  <jsm28@cam.ac.uk>
 
+       * c-decl.c (finish_function): Don't treat 'main' specially unless
+       flag_hosted.  In C99 mode, return 0 from 'main' unless
+       DEFAULT_MAIN_RETURN is otherwise defined.
+
        * c-decl.c (store_parm_decls): In C99 mode, pedwarn for function
        parameters defaulting to int in an old-style function definition.
 
index 0b8621f750f3033bf18c964ebbe5af3ae60bc760..5f69e36136f72d55fcb4cfb6b91cef4352964197 100644 (file)
@@ -6589,7 +6589,8 @@ finish_function (nested)
       setjmp_protect_args ();
     }
 
-  if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main"))
+  if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main")
+      && flag_hosted)
     {
       if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
          != integer_type_node)
@@ -6604,6 +6605,9 @@ finish_function (nested)
 #ifdef DEFAULT_MAIN_RETURN
          /* Make it so that `main' always returns success by default.  */
          DEFAULT_MAIN_RETURN;
+#else
+         if (flag_isoc99)
+           c_expand_return (integer_zero_node);
 #endif
        }
     }