Improve the error message if a qualified void type is used to denote an empty paramet...
authorChristoph Mallon <christoph.mallon@gmx.de>
Sun, 22 Apr 2012 14:16:35 +0000 (16:16 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 24 Apr 2012 12:51:59 +0000 (14:51 +0200)
parser.c

index c5c3545..a1fb923 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3208,6 +3208,8 @@ static void semantic_parameter_incomplete(const entity_t *entity)
 static bool has_parameters(void)
 {
        /* func(void) is not a parameter */
+       if (look_ahead(1)->kind != ')')
+               return true;
        if (token.kind == T_IDENTIFIER) {
                entity_t const *const entity
                        = get_entity(token.identifier.symbol, NAMESPACE_NORMAL);
@@ -3215,13 +3217,16 @@ static bool has_parameters(void)
                        return true;
                if (entity->kind != ENTITY_TYPEDEF)
                        return true;
-               if (skip_typeref(entity->typedefe.type) != type_void)
+               type_t const *const type = skip_typeref(entity->typedefe.type);
+               if (!is_type_void(type))
                        return true;
+               if (type->base.qualifiers != TYPE_QUALIFIER_NONE) {
+                       /* ยง6.7.5.3:10  Qualification is not allowed here. */
+                       errorf(HERE, "'void' as parameter must not have type qualifiers");
+               }
        } else if (token.kind != T_void) {
                return true;
        }
-       if (look_ahead(1)->kind != ')')
-               return true;
        next_token();
        return false;
 }