diff options
| author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-03-26 13:04:30 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 20:59:49 -0700 |
| commit | c61c829ae99356debe09597b1a598a0225a81de8 (patch) | |
| tree | 18f6cff08ff6b1542fbd1a75a7acaaf9a2bdec9c | |
| parent | c37b806b9ac71d4f7359b7592f2a8113afb159f5 (diff) | |
| download | sparse-dev-c61c829ae99356debe09597b1a598a0225a81de8.tar.gz | |
Fix postop and cast evaluators, that returned success when they
failed and caused problems upstream because of that.
Add back compare expressions to the list of expressions that the
pre-processor can evaluate. They got dropped by mistake when they
were split up from the regular binop expressions.
Correctly handle functions with a void argument list. We shouldn't
parse them as a single argument without any associated symbol name ;)
| -rw-r--r-- | evaluate.c | 11 | ||||
| -rw-r--r-- | parse.c | 5 |
2 files changed, 12 insertions, 4 deletions
@@ -205,8 +205,12 @@ static int evaluate_preop(struct expression *expr) warn(expr->token, "cannot derefence this type"); return 0; } - expr->ctype = ctype->ctype.base_type; examine_symbol_type(expr->ctype); + expr->ctype = ctype->ctype.base_type; + if (!expr->ctype) { + warn(expr->token, "undefined type"); + return 0; + } return 1; case '&': { @@ -424,11 +428,11 @@ int evaluate_expression(struct expression *expr) return evaluate_preop(expr); case EXPR_POSTOP: if (!evaluate_expression(expr->unop)) - return 1; + return 0; return evaluate_postop(expr); case EXPR_CAST: if (!evaluate_expression(expr->cast_expression)) - return 1; + return 0; expr->ctype = expr->cast_type; return 1; case EXPR_SIZEOF: @@ -475,6 +479,7 @@ long long get_expression_value(struct expression *expr) #define OP(x,y) case x: return left y right; case EXPR_BINOP: + case EXPR_COMPARE: left = get_expression_value(expr->left); if (!left && expr->op == SPECIAL_LOGICAL_AND) return 0; @@ -685,9 +685,12 @@ static struct token *parameter_type_list(struct token *token, struct symbol *fn) fn->variadic = 1; token = token->next; break; - } + } token = parameter_declaration(token, &sym); + /* Special case: (void) */ + if (!*list && !sym->token && sym->ctype.base_type == &void_ctype) + break; add_symbol(list, sym); if (!match_op(token, ',')) break; |
