Generate a more sensible warning for a stray ; in global context than "no type specif...
[cparser] / parser.c
index d708eb5..71f125b 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3706,7 +3706,7 @@ static expression_t *parse_select_expression(unsigned precedence,
                }
        }
        if(iter == NULL) {
-               errorf(HERE, "'%T' has no member names '%Y'", type_left, symbol);
+               errorf(HERE, "'%T' has no member named '%Y'", orig_type, symbol);
                return create_invalid_expression();
        }
 
@@ -4379,6 +4379,9 @@ static bool has_const_fields(const compound_type_t *type)
        const declaration_t *declaration = context->declarations;
 
        for (; declaration != NULL; declaration = declaration->next) {
+               if (declaration->namespc != NAMESPACE_NORMAL)
+                       continue;
+
                const type_t *decl_type = skip_typeref(declaration->type);
                if (decl_type->base.qualifiers & TYPE_QUALIFIER_CONST)
                        return true;
@@ -5334,7 +5337,13 @@ static translation_unit_t *parse_translation_unit(void)
        initialize_builtin_types();
 
        while(token.type != T_EOF) {
-               parse_external_declaration();
+               if (token.type == ';') {
+                       /* TODO error in strict mode */
+                       warningf(HERE, "stray ';' outside of function");
+                       next_token();
+               } else {
+                       parse_external_declaration();
+               }
        }
 
        assert(context == &unit->context);