diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-10 10:33:33 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-10 18:10:57 +0000 |
commit | ae273ffac99cb75d832a11a83fd63291bb74cbdc (patch) | |
tree | a3d9a44ebe75c96fac728c8f4ed3d0796664ed29 /gcc/rust/rust-gcc.cc | |
parent | 016c40bedc7e3f53e2c413895f77c0d9f723eb3c (diff) | |
download | gcc-ae273ffac99cb75d832a11a83fd63291bb74cbdc.zip gcc-ae273ffac99cb75d832a11a83fd63291bb74cbdc.tar.gz gcc-ae273ffac99cb75d832a11a83fd63291bb74cbdc.tar.bz2 |
Support Break without label and expression
This reuses GENERICS LOOP_EXPR and EXIT_EXPR to implement the infinite
loop.
Addresses: #106 #108
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 0729b1e..82ebb98 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -326,6 +326,10 @@ public: Bstatement *except_stmt, Bstatement *finally_stmt, Location); + Bexpression *loop_expression (Bblock *body, Location); + + Bexpression *exit_expression (Bexpression *condition, Location); + // Blocks. Bblock *block (Bfunction *, Bblock *, const std::vector<Bvariable *> &, @@ -2201,6 +2205,25 @@ Gcc_backend::if_statement (Bfunction *, Bexpression *condition, return this->make_statement (ret); } +// Loops + +Bexpression * +Gcc_backend::loop_expression (Bblock *body, Location locus) +{ + tree loop_expr_tree = fold_build1_loc (locus.gcc_location (), LOOP_EXPR, + void_type_node, body->get_tree ()); + return this->make_expression (loop_expr_tree); +} + +Bexpression * +Gcc_backend::exit_expression (Bexpression *condition, Location locus) +{ + tree cond_tree = condition->get_tree (); + tree exit_expr_tree = fold_build1_loc (locus.gcc_location (), EXIT_EXPR, + void_type_node, cond_tree); + return this->make_expression (exit_expr_tree); +} + // Switch. Bstatement * |