Do not warn, if main() has no prior declaration or prototype.
authorChristoph Mallon <christoph.mallon@gmx.de>
Fri, 14 Dec 2007 17:17:35 +0000 (17:17 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 14 Dec 2007 17:17:35 +0000 (17:17 +0000)
[r18747]

parser.c

index 0dc6489..5ae71c7 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2249,6 +2249,11 @@ static declaration_t *append_declaration(declaration_t* const declaration)
        return declaration;
 }
 
+static bool is_sym_main(const symbol_t *const sym)
+{
+       return strcmp(sym->string, "main") == 0;
+}
+
 static declaration_t *internal_record_declaration(
        declaration_t *const declaration,
        const bool is_function_definition)
@@ -2294,7 +2299,8 @@ static declaration_t *internal_record_declaration(
                                                case STORAGE_CLASS_EXTERN:
                                                        if (is_function_definition) {
                                                                if (warning.missing_prototypes &&
-                                                                   prev_type->function.unspecified_parameters) {
+                                                                   prev_type->function.unspecified_parameters &&
+                                                                   !is_sym_main(symbol)) {
                                                                        warningf(declaration->source_position, "no previous prototype for '%#T'", type, symbol);
                                                                }
                                                        } else if (new_storage_class == STORAGE_CLASS_NONE) {
@@ -2339,9 +2345,9 @@ warn_redundant_declaration:
                }
        } else if (is_function_definition &&
                        declaration->storage_class != STORAGE_CLASS_STATIC) {
-               if (warning.missing_prototypes) {
+               if (warning.missing_prototypes && !is_sym_main(symbol)) {
                        warningf(declaration->source_position, "no previous prototype for '%#T'", type, symbol);
-               } else if (warning.missing_declarations) {
+               } else if (warning.missing_declarations && !is_sym_main(symbol)) {
                        warningf(declaration->source_position, "no previous declaration for '%#T'", type, symbol);
                }
        }