From a191206c644ef3bd1f7ca1f246dda8db2a7c4d68 Mon Sep 17 00:00:00 2001 From: Mitchell Field Date: Thu, 31 Mar 2011 23:06:24 +1100 Subject: [PATCH] Bug 609434 - Don't emit switch statements containing 'default' but no 'case' labels in IPC IPDL files. r=cjones --- ipc/ipdl/ipdl/lower.py | 57 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 01b490763ab..f2f9739acb3 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -3404,35 +3404,36 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): Decl(listenertype, listenervar.name) ], virtual=1)) - switchontype = StmtSwitch(pvar) - for managee in p.managesStmts: - case = StmtBlock() - actorvar = ExprVar('actor') - manageeipdltype = managee.decl.type - manageecxxtype = _cxxBareType(ipdl.type.ActorType(manageeipdltype), - self.side) - manageearray = p.managedVar(manageeipdltype, self.side) + if not len(p.managesStmts): + removemanagee.addstmts([ _runtimeAbort('unreached'), StmtReturn() ]) + else: + switchontype = StmtSwitch(pvar) + for managee in p.managesStmts: + case = StmtBlock() + actorvar = ExprVar('actor') + manageeipdltype = managee.decl.type + manageecxxtype = _cxxBareType(ipdl.type.ActorType(manageeipdltype), + self.side) + manageearray = p.managedVar(manageeipdltype, self.side) - case.addstmts([ - StmtDecl(Decl(manageecxxtype, actorvar.name), - ExprCast(listenervar, manageecxxtype, static=1)), - _abortIfFalse( - _cxxArrayHasElementSorted(manageearray, actorvar), - "actor not managed by this!"), - Whitespace.NL, - StmtExpr(_callCxxArrayRemoveSorted(manageearray, actorvar)), - StmtExpr(ExprCall(_deallocMethod(manageeipdltype), - args=[ actorvar ])), - StmtReturn() - ]) - switchontype.addcase(CaseLabel(_protocolId(manageeipdltype).name), - case) - - default = StmtBlock() - default.addstmts([ _runtimeAbort('unreached'), StmtReturn() ]) - switchontype.addcase(DefaultLabel(), default) - - removemanagee.addstmt(switchontype) + case.addstmts([ + StmtDecl(Decl(manageecxxtype, actorvar.name), + ExprCast(listenervar, manageecxxtype, static=1)), + _abortIfFalse( + _cxxArrayHasElementSorted(manageearray, actorvar), + "actor not managed by this!"), + Whitespace.NL, + StmtExpr(_callCxxArrayRemoveSorted(manageearray, actorvar)), + StmtExpr(ExprCall(_deallocMethod(manageeipdltype), + args=[ actorvar ])), + StmtReturn() + ]) + switchontype.addcase(CaseLabel(_protocolId(manageeipdltype).name), + case) + default = StmtBlock() + default.addstmts([ _runtimeAbort('unreached'), StmtReturn() ]) + switchontype.addcase(DefaultLabel(), default) + removemanagee.addstmt(switchontype) return [ register, registerid,