Re: [PATCH] Allow matching of empty structs and arrays
[Thread Prev] | [Thread Next]
- Subject: Re: [PATCH] Allow matching of empty structs and arrays
- From: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Date: Sat, 8 Jul 2017 23:50:15 -0700
- To: "S. Gilles" <sgilles@xxxxxxxxxxxx>
- Cc: "myrddin-dev" <myrddin-dev@xxxxxxxxxxxxxx>
On Sun, 9 Jul 2017 01:47:07 -0400, "S. Gilles" <sgilles@xxxxxxxxxxxx> wrote: > --- > This is regarding conversation on #myrddin. Please let me know if > something should be changed in style or substance. > > mi/match.c | 8 +++++--- > test/empty-struct.myr | 26 ++++++++++++++++++++++++++ > test/tests | 1 + > 3 files changed, 32 insertions(+), 3 deletions(-) > create mode 100644 test/empty-struct.myr > > diff --git a/mi/match.c b/mi/match.c > index 29f8cc44..3d159624 100644 > --- a/mi/match.c > +++ b/mi/match.c > @@ -246,9 +246,11 @@ static int acceptall(Dtree *t, Dtree *accept) > return ret; > } > > -static int isbasictype(Dtree *dt, Type *ty) > +static int isnonrecursive(Dtree *dt, Type *ty) > { > - return istyprimitive(ty) || ty->type == Tyvoid || ty->type == Tyfunc || ty->type == Typtr; > + return istyprimitive(ty) || ty->type == Tyvoid || ty->type == Tyfunc || > + ty->type == Typtr || (ty->type == Tystruct && ty->nmemb == 0) || > + (ty->type == Tyarray && fold(ty->asize, 1)->expr.args[0]->lit.intval == 0); > } Just a minor stylistic nitpick: I'd break up the condition into a few smaller cases -- it's getting unweildy to read. Another minor nit is that wrapped statements get an extra leading tab: foo && bar && baz Not worth another round of back and forth, so I just fixed them when I committed. -- Ori Bernstein
[PATCH] Allow matching of empty structs and arrays | "S. Gilles" <sgilles@xxxxxxxxxxxx> |
- Prev by Date: [PATCH] Allow matching of empty structs and arrays
- Next by Date: Warning: Incoming Syntax Change.
- Previous by thread: [PATCH] Allow matching of empty structs and arrays
- Next by thread: Warning: Incoming Syntax Change.
- Index(es):