aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-07-10 17:56:40 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-07-10 17:56:40 +0000
commit41112d9519d48a503864a157d90fd3c6ef974bfe (patch)
tree428f83007d8eb2564561333bb23809f32a8f7b41
parentb59ff58620d1d4ffff5c74bd9f9f10f3cb222d8e (diff)
downloadgcc-41112d9519d48a503864a157d90fd3c6ef974bfe.zip
gcc-41112d9519d48a503864a157d90fd3c6ef974bfe.tar.gz
gcc-41112d9519d48a503864a157d90fd3c6ef974bfe.tar.bz2
compiler: add break label in 1,2-case select statement lowering
CL 184998 added optimizations for one- and two-case select statements. But it didn't handle break statement in the select case correctly. Specifically, it didn't add the label definition, so it could result in a dangling goto. This CL fixes this, by adding the label definition. A test case is CL 185520. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/185519 From-SVN: r273359
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/statements.cc8
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 410afb0..582ded3 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-7a8e10be0ddb8909ce25a264d03b24cee4df60cc
+170ecdf6b2eab8aac2b8c852fa95d3c36d6bf604
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 1e88fab..b0b576f 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -5855,6 +5855,10 @@ Select_statement::lower_one_case(Block* b)
Statement::make_block_statement(scase.statements(), scase.location());
b->add_statement(bs);
+ Statement* label =
+ Statement::make_unnamed_label_statement(this->break_label());
+ b->add_statement(label);
+
this->is_lowered_ = true;
return Statement::make_block_statement(b, loc);
}
@@ -5958,6 +5962,10 @@ Select_statement::lower_two_case(Block* b)
Statement::make_if_statement(call, bchan, defcase.statements(), loc);
b->add_statement(ifs);
+ Statement* label =
+ Statement::make_unnamed_label_statement(this->break_label());
+ b->add_statement(label);
+
this->is_lowered_ = true;
return Statement::make_block_statement(b, loc);
}