URI:
       cc2: Keep label position in branches - scc - simple c99 compiler
  HTML git clone git://git.simple-cc.org/scc
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 61adffcdcf6e9aeb0c762fb0ba3974d6c2e648c4
   DIR parent 91d6c4c2e9cf507de205fab129a65be40fb1c6b3
  HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
       Date:   Tue, 10 Feb 2026 11:26:43 +0100
       
       cc2: Keep label position in branches
       
       When a branch is transformed into a set of jumps new statements are
       inserted before the current statement, displacing the relative position
       of the label of the current statement in case of having one. For that
       reason in this case we have to create a label statment and place there
       the label.
       
       Diffstat:
         M src/cmd/scc-cc/cc2/sethi.c          |       1 +
         A tests/cc/execute/0246-branch.c      |      17 +++++++++++++++++
         M tests/cc/execute/scc-tests.lst      |       1 +
       
       3 files changed, 19 insertions(+), 0 deletions(-)
       ---
   DIR diff --git a/src/cmd/scc-cc/cc2/sethi.c b/src/cmd/scc-cc/cc2/sethi.c
       @@ -170,6 +170,7 @@ sethi(Node *np)
                        np = swtch(np);
                        break;
                case OBRANCH:
       +                keeplabel();
                        next = np->next;
                        if (!next->label)
                                labelstmt(next, NULL);
   DIR diff --git a/tests/cc/execute/0246-branch.c b/tests/cc/execute/0246-branch.c
       @@ -0,0 +1,17 @@
       +int but, aclick;
       +
       +int
       +main(void)
       +{
       +        int r;
       +
       +        aclick = 1;
       +        but = 1;
       +        r = 1;
       +        if (aclick == 1 && but == 1) {
       +                if (aclick == 1 && but == 1)
       +                        r = 0;
       +        }
       +
       +        return r;
       +}
   DIR diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst
       @@ -236,3 +236,4 @@
        0243-ternary.c
        0244-logic.c
        0245-comma.c
       +0246-branch.c