diff --git a/ipc/ipdl/ipdl/ast.py b/ipc/ipdl/ipdl/ast.py index f1e7239b2237..dcf0152a13ed 100644 --- a/ipc/ipdl/ipdl/ast.py +++ b/ipc/ipdl/ipdl/ast.py @@ -355,10 +355,11 @@ class MessageDecl(Node): class Param(Node): - def __init__(self, loc, typespec, name): + def __init__(self, loc, typespec, name, attributes={}): Node.__init__(self, loc) self.name = name self.typespec = typespec + self.attributes = attributes class TypeSpec(Node): diff --git a/ipc/ipdl/ipdl/parser.py b/ipc/ipdl/ipdl/parser.py index f8f7bd5a3922..bb48400d3212 100644 --- a/ipc/ipdl/ipdl/parser.py +++ b/ipc/ipdl/ipdl/parser.py @@ -633,8 +633,8 @@ def p_ParamList(p): def p_Param(p): - """Param : Type ID""" - p[0] = Param(locFromTok(p, 1), p[1], p[2]) + """Param : Attributes Type ID""" + p[0] = Param(locFromTok(p, 2), p[2], p[3], p[1]) def p_Type(p): diff --git a/ipc/ipdl/ipdl/type.py b/ipc/ipdl/ipdl/type.py index 8d680a19d268..cebfac988eba 100644 --- a/ipc/ipdl/ipdl/type.py +++ b/ipc/ipdl/ipdl/type.py @@ -1297,9 +1297,24 @@ class GatherDecls(TcheckVisitor): # replace inparam Param nodes with proper Decls def paramToDecl(param): + self.checkAttributes( + param.attributes, + { + "NoTaint": ("passback",) + }, + ) + ptname = param.typespec.basename() ploc = param.typespec.loc + if 'NoTaint' in param.attributes and 'Tainted' not in md.attributes: + self.error( + ploc, + "argument typename `%s' of message `%s' has a NoTaint attribute, but the message lacks the Tainted attribute", + ptname, + msgname, + ) + ptdecl = self.symtab.lookup(ptname) if ptdecl is None: self.error( diff --git a/ipc/ipdl/test/ipdl/error/PNoTaintWithoutTainted.ipdl b/ipc/ipdl/test/ipdl/error/PNoTaintWithoutTainted.ipdl new file mode 100644 index 000000000000..cfdde1f02c67 --- /dev/null +++ b/ipc/ipdl/test/ipdl/error/PNoTaintWithoutTainted.ipdl @@ -0,0 +1,6 @@ +//error: argument typename `int' of message `foo' has a NoTaint attribute, but the message lacks the Tainted attribute + +intr protocol PNoTaintWithoutTainted { +child: + async foo([NoTaint=passback] int id); +}; diff --git a/ipc/ipdl/test/ipdl/ok/PMessageTaintedWithPassback.ipdl b/ipc/ipdl/test/ipdl/ok/PMessageTaintedWithPassback.ipdl new file mode 100644 index 000000000000..1d03e97e7394 --- /dev/null +++ b/ipc/ipdl/test/ipdl/ok/PMessageTaintedWithPassback.ipdl @@ -0,0 +1,4 @@ +intr protocol PMessageTaintedWithPassback { +child: + [Tainted] async foo([NoTaint=passback] int id); +};