aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-11-12 00:54:47 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2022-11-30 15:36:14 +0100
commit031d3f095520f0e1ee03e29b7ad5067c2a3f96e0 (patch)
tree2e258bdfb175613a8573c7b703ce8afcf72a4feb /gcc/testsuite/gdc.dg
parentd0a3d55ae4a2656f7c306c9345ba14853b4075d5 (diff)
downloadgcc-031d3f095520f0e1ee03e29b7ad5067c2a3f96e0.zip
gcc-031d3f095520f0e1ee03e29b7ad5067c2a3f96e0.tar.gz
gcc-031d3f095520f0e1ee03e29b7ad5067c2a3f96e0.tar.bz2
d: Fix ICE on named continue label in an unrolled loop [PR107592]
Continue labels in an unrolled loop require a unique label per iteration. Previously this used the Statement body node for each unrolled iteration to generate a new entry in the label hash table. This does not work when the continue label has an identifier, as said named label is pointing to the outer UnrolledLoopStatement node. What would happen is that during the lowering of `continue label', an automatic label associated with the unrolled loop would be generated, and a jump to that label inserted, but because it was never pushed by the visitor for the loop itself, it subsequently never gets emitted. To fix, correctly use the UnrolledLoopStatement as the key to look up and store the break/continue label pair, but remove the continue label from the value entry after every loop to force a new label to be generated by the next call to `push_continue_label' PR d/107592 gcc/d/ChangeLog: * toir.cc (IRVisitor::push_unrolled_continue_label): New method. (IRVisitor::pop_unrolled_continue_label): New method. (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of push_continue_label and pop_continue_label. gcc/testsuite/ChangeLog: * gdc.dg/pr107592.d: New test.
Diffstat (limited to 'gcc/testsuite/gdc.dg')
-rw-r--r--gcc/testsuite/gdc.dg/pr107592.d13
1 files changed, 13 insertions, 0 deletions
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);