diff --git a/ipc/ipdl/ipdl/parser.py b/ipc/ipdl/ipdl/parser.py index a9e987a56c07..5ef785a01811 100644 --- a/ipc/ipdl/ipdl/parser.py +++ b/ipc/ipdl/ipdl/parser.py @@ -269,7 +269,7 @@ def p_NamespacedProtocolDefn(p): p[0] = protocol def p_ProtocolDefn(p): - """ProtocolDefn : OptionalSendSemanticsQual PROTOCOL ID '{' ManagerStmtOpt ManagesStmts MessageDecls TransitionStmts '}' ';'""" + """ProtocolDefn : OptionalSendSemanticsQual PROTOCOL ID '{' ManagerStmtOpt ManagesStmts OptionalMessageDecls TransitionStmts '}' ';'""" protocol = Protocol(locFromTok(p, 2)) protocol.name = p[3] protocol.sendSemantics = p[1] @@ -300,6 +300,14 @@ def p_ManagesStmt(p): """ManagesStmt : MANAGES ID ';'""" p[0] = ManagesStmt(locFromTok(p, 1), p[2]) +def p_OptionalMessageDecls(p): + """OptionalMessageDecls : MessageDecls + | """ + if 2 == len(p): + p[0] = p[1] + else: + p[0] = [ ] + def p_MessageDecls(p): """MessageDecls : MessageDecls MessageDeclThing | MessageDeclThing""" diff --git a/ipc/ipdl/ipdl/type.py b/ipc/ipdl/ipdl/type.py index 370e4ce04a72..f4b40ef8391e 100644 --- a/ipc/ipdl/ipdl/type.py +++ b/ipc/ipdl/ipdl/type.py @@ -437,6 +437,11 @@ class GatherDecls(TcheckVisitor): managed.manager = p managed.accept(self) + if p.manager is None and 0 == len(p.messageDecls): + self.error(p.loc, + "top-level protocol `%s' cannot be empty", + p.name) + setattr(self, 'currentProtocolDecl', p.decl) for msg in p.messageDecls: msg.accept(self)