issue49.t 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=49
  3. # B::CC Can't "last" outside a loop block
  4. use Test::More tests => 1;
  5. use strict;
  6. BEGIN {
  7. unshift @INC, 't';
  8. require "test.pl";
  9. }
  10. # The op "leaveloop" is not handled by B::CC because it is dead code.
  11. # Hence @cxstack only is increased by "enterloop", but never
  12. # decreased. Hence the second op "last" in the test program reads
  13. # loop data from the wrong context and jumps to the end of the inner
  14. # loop by mistake. This issue is similar to issue 47 but not fixable
  15. # that easy. We either have to rethink handling of dead code or have
  16. # to pop @cxstack not only for "leavesub" but somehow for op "last" as
  17. # well. But that is difficult, because there can be multiple "last"
  18. # ops.
  19. my $script = <<'EOF';
  20. while (1) {
  21. while (1) {
  22. last;
  23. }
  24. last;
  25. }
  26. EOF
  27. use B::CC;
  28. ccompileok(1, "CC", "ccode49i", $script, # fixed with B::CC 1.08 r625
  29. ($B::CC::VERSION < 1.08 ? "TODO " : "")
  30. . "CC Can't \"last\" outside a loop block, fixed with B-C-1.28");