aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.c
diff options
authorLinus Torvalds <torvalds@home.transmeta.com>2003-03-25 11:49:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 20:59:45 -0700
commit50693db0e53525b90459a31b8f5bc6449538565a (patch)
tree096c69288652950100afc2abe65530ce1e4a156b /expression.c
parent5d9eaa3804ab311a2cc08969eae2d6ef346cc5cb (diff)
downloadsparse-dev-50693db0e53525b90459a31b8f5bc6449538565a.tar.gz
Start doing type evaluation for binops - integer promotion rules
etc. Add a function call expression type. Make expression type evaluation return a success/failure value.
Diffstat (limited to 'expression.c')
-rw-r--r--expression.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/expression.c b/expression.c
index fe054bc6..f4e88a48 100644
--- a/expression.c
+++ b/expression.c
@@ -101,12 +101,17 @@ static struct token *postfix_expression(struct token *token, struct expression *
while (expr && token->type == TOKEN_SPECIAL) {
switch (token->special) {
case '[': { /* Array dereference */
- struct expression *array_expr = alloc_expression(token, EXPR_BINOP);
- array_expr->op = '[';
- array_expr->left = expr;
- token = parse_expression(token->next, &array_expr->right);
+ struct expression *deref = alloc_expression(token, EXPR_PREOP);
+ struct expression *add = alloc_expression(token, EXPR_BINOP);
+
+ deref->op = '*';
+ deref->unop = add;
+
+ add->op = '+';
+ add->left = expr;
+ token = parse_expression(token->next, &add->right);
token = expect(token, ']', "at end of array dereference");
- expr = array_expr;
+ expr = deref;
continue;
}
case SPECIAL_INCREMENT: /* Post-increment */
@@ -135,7 +140,7 @@ static struct token *postfix_expression(struct token *token, struct expression *
}
case '(': { /* Function call */
- struct expression *call = alloc_expression(token, EXPR_BINOP);
+ struct expression *call = alloc_expression(token, EXPR_CALL);
call->op = '(';
call->left = expr;
token = comma_expression(token->next, &call->right);