Also do not warn about function declarations without a prior declaration. *sigh*
[cparser] / parser.c
index 3a3fd39..5fa99de 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2343,16 +2343,20 @@ warn_redundant_declaration:
                        }
                        return previous_declaration;
                }
-       } else if (is_function_definition &&
-                       declaration->storage_class != STORAGE_CLASS_STATIC) {
-               if (warning.missing_prototypes && !is_sym_main(symbol)) {
-                       warningf(declaration->source_position, "no previous prototype for '%#T'", type, symbol);
-               } else if (warning.missing_declarations && !is_sym_main(symbol)) {
-                       warningf(declaration->source_position, "no previous declaration for '%#T'", type, symbol);
+       } else if (is_function_definition) {
+               if (declaration->storage_class != STORAGE_CLASS_STATIC) {
+                       if (warning.missing_prototypes && !is_sym_main(symbol)) {
+                               warningf(declaration->source_position, "no previous prototype for '%#T'", type, symbol);
+                       } else if (warning.missing_declarations && !is_sym_main(symbol)) {
+                               warningf(declaration->source_position, "no previous declaration for '%#T'", type, symbol);
+                       }
                }
        } else if (warning.missing_declarations &&
-           declaration->storage_class != STORAGE_CLASS_STATIC &&
-           declaration->storage_class != STORAGE_CLASS_TYPEDEF) {
+           context == global_context &&
+           !is_type_function(type) && (
+             declaration->storage_class == STORAGE_CLASS_NONE ||
+             declaration->storage_class == STORAGE_CLASS_THREAD
+           )) {
                warningf(declaration->source_position, "no previous declaration for '%#T'", type, symbol);
        }
 
@@ -5023,7 +5027,14 @@ static statement_t *parse_label_statement(void)
                errorf(HERE, "label at end of compound statement");
                return (statement_t*) label_statement;
        } else {
-               label_statement->label_statement = parse_statement();
+               if (token.type == ';') {
+                       /* eat an empty statement here, to avoid the warning about an empty
+                        * after a label.  label:; is commonly used to have a label before
+                        * a }. */
+                       next_token();
+               } else {
+                       label_statement->label_statement = parse_statement();
+               }
        }
 
        return (statement_t*) label_statement;