aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/d/toir.cc26
-rw-r--r--gcc/testsuite/gdc.dg/pr107592.d13
2 files changed, 37 insertions, 2 deletions
diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc
index e5f5751..e387f27 100644
--- a/gcc/d/toir.cc
+++ b/gcc/d/toir.cc
@@ -529,6 +529,28 @@ public:
this->do_label (label);
}
+ /* Generate and set a new continue label for the current unrolled loop. */
+
+ void push_unrolled_continue_label (UnrolledLoopStatement *s)
+ {
+ this->push_continue_label (s);
+ }
+
+ /* Finish with the continue label for the unrolled loop. */
+
+ void pop_unrolled_continue_label (UnrolledLoopStatement *s)
+ {
+ Statement *stmt = s->getRelatedLabeled ();
+ d_label_entry *ent = d_function_chain->labels->get (stmt);
+ gcc_assert (ent != NULL && ent->bc_label == true);
+
+ this->pop_continue_label (TREE_VEC_ELT (ent->label, bc_continue));
+
+ /* Remove the continue label from the label htab, as a new one must be
+ inserted at the end of every unrolled loop. */
+ ent->label = TREE_VEC_ELT (ent->label, bc_break);
+ }
+
/* Visitor interfaces. */
@@ -1089,9 +1111,9 @@ public:
if (statement != NULL)
{
- tree lcontinue = this->push_continue_label (statement);
+ this->push_unrolled_continue_label (s);
this->build_stmt (statement);
- this->pop_continue_label (lcontinue);
+ this->pop_unrolled_continue_label (s);
}
}
diff --git a/gcc/testsuite/gdc.dg/pr107592.d b/gcc/testsuite/gdc.dg/pr107592.d
new file mode 100644
index 0000000..59f3447
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr107592.d
@@ -0,0 +1,13 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592
+// { dg-do compile }
+
+void test107592(Things...)(Things things)
+{
+ label:
+ foreach (thing; things)
+ {
+ continue label;
+ }
+}
+
+alias a107592 = test107592!(string);