Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix g++ build (Add extra scope block for switch case) #20109

Merged
merged 1 commit into from
Aug 17, 2022

Commits on Aug 17, 2022

  1. 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
    Bram committed Aug 17, 2022
    Configuration menu
    Copy the full SHA
    fa3e3c8 View commit details
    Browse the repository at this point in the history