diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-08 21:57:59 +0200 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-08 22:02:18 +0200 |
commit | 49a09af117be32adf230efd2c52a41f810b9ee04 (patch) | |
tree | b80a467ae0cf80347884d81b45332229fe9a236a /gcc/d/expr.cc | |
parent | 8cd239614e43c9dcc0838845aec504e5eb938dbd (diff) | |
download | gcc-49a09af117be32adf230efd2c52a41f810b9ee04.zip gcc-49a09af117be32adf230efd2c52a41f810b9ee04.tar.gz gcc-49a09af117be32adf230efd2c52a41f810b9ee04.tar.bz2 |
d: Merge upstream dmd 955b8b36f.
Merges AndAndExp and OrOrExp into a LogicalExp AST node.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 955b8b36f.
* expr.cc (ExprVisitor::visit (AndAndExp *)): Rename type to ...
(ExprVisitor::visit (LogicalExp *)): ... this. Handle both 'and if'
and 'or if' expression nodes.
(ExprVisitor::visit (OrOrExp *)): Remove.
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r-- | gcc/d/expr.cc | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 562e35a..41d9796 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -545,11 +545,14 @@ public: this->result_ = d_convert (build_ctype (e->type), result); } - /* Build an `and if' expression. If the right operand expression is void, - then the resulting type is void. Otherwise the result is bool. */ + /* Build a logical `and if' or `or if' expression. If the right operand + expression is void, then the resulting type is void. Otherwise the + result is bool. */ - void visit (AndAndExp *e) + void visit (LogicalExp *e) { + tree_code code = (e->op == TOKandand) ? TRUTH_ANDIF_EXPR : TRUTH_ORIF_EXPR; + if (e->e2->type->toBasetype ()->ty != Tvoid) { tree t1 = build_expr (e->e1); @@ -559,39 +562,19 @@ public: t2 = convert_for_condition (t2, e->e2->type); this->result_ = d_convert (build_ctype (e->type), - build_boolop (TRUTH_ANDIF_EXPR, t1, t2)); + build_boolop (code, t1, t2)); } else { tree t1 = convert_for_condition (build_expr (e->e1), e->e1->type); tree t2 = build_expr_dtor (e->e2); - this->result_ = build_condition (build_ctype (e->type), - t1, t2, void_node); - } - } - - /* Build an `or if' expression. If the right operand expression is void, - then the resulting type is void. Otherwise the result is bool. */ - - void visit (OrOrExp *e) - { - if (e->e2->type->toBasetype ()->ty != Tvoid) - { - tree t1 = convert_for_condition (build_expr (e->e1), e->e1->type); - tree t2 = convert_for_condition (build_expr (e->e2), e->e2->type); - - this->result_ = d_convert (build_ctype (e->type), - build_boolop (TRUTH_ORIF_EXPR, t1, t2)); - } - else - { - tree t1 = convert_for_condition (build_expr (e->e1), e->e1->type); - tree t2 = build_expr_dtor (e->e2); - tree cond = build1 (TRUTH_NOT_EXPR, d_bool_type, t1); + /* Invert condition for logical or if expression. */ + if (e->op == TOKoror) + t1 = build1 (TRUTH_NOT_EXPR, d_bool_type, t1); this->result_ = build_condition (build_ctype (e->type), - cond, t2, void_node); + t1, t2, void_node); } } |