summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2017-07-09 01:47:07 -0400
committerOri Bernstein <ori@eigenstate.org>2017-07-08 23:44:21 -0700
commit32397d07defce76d42a038e8b6b339b8a0c14699 (patch)
tree13d72e46758f8c13f90a5082926b000d788ff086 /mi
parent5317028311f7eda55ab588bfca93f27bbb5cd839 (diff)
downloadmc-32397d07defce76d42a038e8b6b339b8a0c14699.tar.gz
Allow matching of empty structs and arrays
Diffstat (limited to 'mi')
-rw-r--r--mi/match.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mi/match.c b/mi/match.c
index 29f8cc4..3d15962 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);
}
static int ismatchable(Type *ty)
@@ -269,7 +271,7 @@ static int addwildrec(Srcloc loc, Type *ty, Dtree *start, Dtree *accept, Dtree *
ty = tybase(ty);
if (ty->type == Typtr && start->any && start->any->ptrwalk) {
return addwildrec(loc, ty->sub[0], start->any, accept, end, nend);
- } else if (isbasictype(start, ty)) {
+ } else if (isnonrecursive(start, ty)) {
if (start->accept || start == accept)
return 0;
for (i = 0; i < start->nnext; i++)