diff options
author | Bram <perl-rt@wizbit.be> | 2022-08-17 18:18:45 +0200 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-08-17 12:04:02 -0600 |
commit | 2652cd703551f693e6a7476e2ae1886f51391cae (patch) | |
tree | 1863e919a10e4d27a99a9f7206fe163da0c8e3cf /peep.c | |
parent | e8fd52ac0235a2f4010222402aaa63a55353f057 (diff) | |
download | perl-2652cd703551f693e6a7476e2ae1886f51391cae.tar.gz |
Add extra scope block for switch case (fix g++)
Code in 9fdd7fc4796d89d16dceea42f2af91e4fde296ed 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 #20108
Diffstat (limited to 'peep.c')
-rw-r--r-- | peep.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -3799,7 +3799,7 @@ Perl_rpeep(pTHX_ OP *o) } break; - case OP_SASSIGN: + case OP_SASSIGN: { if (OP_GIMME(o,0) == G_VOID || ( o->op_next->op_type == OP_LINESEQ && ( o->op_next->op_next->op_type == OP_LEAVESUB @@ -3893,6 +3893,7 @@ Perl_rpeep(pTHX_ OP *o) oldoldop = NULL; oldop = NULL; } break; + } case OP_AASSIGN: { int l, r, lr, lscalars, rscalars; |