aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.c
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-19 21:04:32 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-19 21:04:32 -0700
commit5343861e409cb1f6f4dd710a7e7feecb079fbd94 (patch)
tree69f62f9efb813a242aaefd5556c53a0bd83519dc /expression.c
parentcf9816ef7a1f16e06ea1a2ba4581bb4278ed62ee (diff)
downloadsparse-dev-5343861e409cb1f6f4dd710a7e7feecb079fbd94.tar.gz
Fix assignment and conditional expression parsing with no left side.
We used to parse it with a NULL left side, which just doesn't make any sense. Refuse to recognize it instead.
Diffstat (limited to 'expression.c')
-rw-r--r--expression.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/expression.c b/expression.c
index 8a1b40e6..310aa17e 100644
--- a/expression.c
+++ b/expression.c
@@ -696,7 +696,7 @@ static struct token *logical_or_expression(struct token *token, struct expressio
struct token *conditional_expression(struct token *token, struct expression **tree)
{
token = logical_or_expression(token, tree);
- if (match_op(token, '?')) {
+ if (*tree && match_op(token, '?')) {
struct expression *expr = alloc_expression(token->pos, EXPR_CONDITIONAL);
expr->op = token->special;
expr->left = *tree;
@@ -711,7 +711,7 @@ struct token *conditional_expression(struct token *token, struct expression **tr
struct token *assignment_expression(struct token *token, struct expression **tree)
{
token = conditional_expression(token, tree);
- if (token_type(token) == TOKEN_SPECIAL) {
+ if (*tree && token_type(token) == TOKEN_SPECIAL) {
static const int assignments[] = {
'=',
SPECIAL_ADD_ASSIGN, SPECIAL_SUB_ASSIGN,