diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-12-21 17:00:43 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2013-12-21 17:00:43 +0000 |
commit | 1cd385f3b354a78ae8d02333f40cd065073c9b19 (patch) | |
tree | 923e490d77d414280d91918bcf5c35b93df78ab0 /cfrontend/C2C.ml | |
parent | 1c768ee3ff91e826f52cf08e1aaa8c4d637240f5 (diff) |
Support "default" cases in the middle of a "switch", not just at the end.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2383 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/C2C.ml')
-rw-r--r-- | cfrontend/C2C.ml | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index 850682e..f12efa3 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -742,22 +742,20 @@ let rec convertStmt ploc env s = and convertSwitch ploc env = function | [] -> - LSdefault Sskip - | [Default, s] -> - LSdefault (convertStmt ploc env s) - | (Default, s) :: _ -> + LSnil + | (lbl, s) :: rem -> updateLoc s.sloc; - unsupported "'default' case must occur last"; - LSdefault Sskip - | (Case e, s) :: rem -> - updateLoc s.sloc; - let v = - match Ceval.integer_expr env e with - | None -> unsupported "'case' label is not a compile-time integer"; 0L - | Some v -> v in - LScase(convertInt v, - convertStmt ploc env s, - convertSwitch s.sloc env rem) + let lbl' = + match lbl with + | Default -> + None + | Case e -> + match Ceval.integer_expr env e with + | None -> unsupported "'case' label is not a compile-time integer"; + None + | Some v -> Some (convertInt v) + in + LScons(lbl', convertStmt ploc env s, convertSwitch s.sloc env rem) (** Function definitions *) |