From c3b6ccf01b43193b705a1f4332e9b28b7ace3938 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 1 Aug 2004 20:17:28 -0700 Subject: [PATCH] Add "select" expression. It's the same as a regular C conditional, except you could evaluate both sides first. Right now we treat it exactly the same as an EXPR_CONDITIONAL. --- compile-i386.c | 1 + evaluate.c | 1 + expand.c | 1 + expression.h | 2 ++ inline.c | 1 + linearize.c | 1 + show-parse.c | 1 + 7 files changed, 8 insertions(+) diff --git a/compile-i386.c b/compile-i386.c index 289bfe43..dace9717 100644 --- a/compile-i386.c +++ b/compile-i386.c @@ -2144,6 +2144,7 @@ static struct storage *x86_expression(struct expression *expr) case EXPR_INITIALIZER: x86_initializer_expr(expr, expr->ctype); return NULL; + case EXPR_SELECT: case EXPR_CONDITIONAL: return emit_conditional_expr(expr); case EXPR_STATEMENT: diff --git a/evaluate.c b/evaluate.c index 9f2ddbaa..b508e04b 100644 --- a/evaluate.c +++ b/evaluate.c @@ -1863,6 +1863,7 @@ struct symbol *evaluate_expression(struct expression *expr) case EXPR_BITFIELD: warn(expr->pos, "bitfield generated by parser"); return NULL; + case EXPR_SELECT: case EXPR_CONDITIONAL: if (!evaluate_conditional(&expr->conditional)) return NULL; diff --git a/expand.c b/expand.c index 35f0b203..d52e42ee 100644 --- a/expand.c +++ b/expand.c @@ -676,6 +676,7 @@ static void expand_expression(struct expression *expr) expand_expression(expr->address); return; + case EXPR_SELECT: case EXPR_CONDITIONAL: expand_expression(expr->conditional); expand_expression(expr->cond_false); diff --git a/expression.h b/expression.h index 5d5612de..d03cdc35 100644 --- a/expression.h +++ b/expression.h @@ -28,6 +28,7 @@ enum expression_type { EXPR_SIZEOF, EXPR_ALIGNOF, EXPR_CONDITIONAL, + EXPR_SELECT, // a "safe" conditional expression EXPR_STATEMENT, EXPR_CALL, EXPR_COMMA, @@ -83,6 +84,7 @@ struct expression { struct expression *cast_expression; }; // EXPR_CONDITIONAL + // EXPR_SELECT struct /* conditional_expr */ { struct expression *conditional, *cond_true, *cond_false; }; diff --git a/inline.c b/inline.c index 9b30d45b..6591a5e0 100644 --- a/inline.c +++ b/inline.c @@ -130,6 +130,7 @@ static struct expression * copy_expression(struct expression *expr) } /* Conditional expression */ + case EXPR_SELECT: case EXPR_CONDITIONAL: { struct expression *cond = copy_expression(expr->conditional); struct expression *true = copy_expression(expr->cond_true); diff --git a/linearize.c b/linearize.c index bbeef884..ddca288c 100644 --- a/linearize.c +++ b/linearize.c @@ -741,6 +741,7 @@ pseudo_t linearize_expression(struct entrypoint *ep, struct expression *expr) case EXPR_COMPARE: return linearize_compare(ep, expr); + case EXPR_SELECT: case EXPR_CONDITIONAL: return linearize_conditional(ep, expr, expr->conditional, expr->cond_true, expr->cond_false); diff --git a/show-parse.c b/show-parse.c index efe55811..ab49d517 100644 --- a/show-parse.c +++ b/show-parse.c @@ -986,6 +986,7 @@ int show_expression(struct expression *expr) return show_bitfield_expr(expr); case EXPR_INITIALIZER: return show_initializer_expr(expr, expr->ctype); + case EXPR_SELECT: case EXPR_CONDITIONAL: return show_conditional_expr(expr); case EXPR_STATEMENT: -- 2.11.4.GIT