Skip to content

Commit fa3e3c8

Browse files
author
Bram
committed
Add extra scope block for switch case (fix g++)
Code in 9fdd7fc broke the g++ builds, Basically after the commit the code looked like: switch (o->op_type) { ... case OP_SASSIGN: ... OP* rhs = cBINOPx(o)->op_first; OP* lval = cBINOPx(o)->op_last; ... break; case OP_AASSIGN: { g++ does not allow this and errors with: peep.c:3897:14: error: jump to case label 3897 | case OP_AASSIGN: { | ^~~~~~~~~~ peep.c:3844:17: note: crosses initialization of 'OP* lval' 3844 | OP* lval = cBINOPx(o)->op_last; | ^~~~ peep.c:3843:17: note: crosses initialization of 'OP* rhs' 3843 | OP* rhs = cBINOPx(o)->op_first; | ^~~ This happens because `rhs` and `lval` are not scoped in the case statement so it could fall through to the next case. The solution is to scope them which this commit now does by adding a separate scope for `OP_SASSIGN` (similar to `OP_AASSIGN`). Fixes Perl#20108
1 parent e8fd52a commit fa3e3c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

peep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3799,7 +3799,7 @@ Perl_rpeep(pTHX_ OP *o)
37993799
}
38003800
break;
38013801

3802-
case OP_SASSIGN:
3802+
case OP_SASSIGN: {
38033803
if (OP_GIMME(o,0) == G_VOID
38043804
|| ( o->op_next->op_type == OP_LINESEQ
38053805
&& ( o->op_next->op_next->op_type == OP_LEAVESUB
@@ -3893,6 +3893,7 @@ Perl_rpeep(pTHX_ OP *o)
38933893
oldoldop = NULL; oldop = NULL;
38943894
}
38953895
break;
3896+
}
38963897

38973898
case OP_AASSIGN: {
38983899
int l, r, lr, lscalars, rscalars;

0 commit comments

Comments
 (0)