summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/blob.c1
-rw-r--r--6/isel.c1
-rw-r--r--6/simp.c10
-rw-r--r--lib/cryptohash/md5.myr2
-rw-r--r--lib/cryptohash/sha1.myr2
-rw-r--r--lib/cryptohash/sha256.myr4
-rw-r--r--lib/cryptohash/sha512.myr4
-rw-r--r--lib/regex/compile.myr6
-rw-r--r--lib/regex/interp.myr2
-rw-r--r--lib/std/alloc.myr2
-rw-r--r--lib/std/memops-impl.myr2
-rw-r--r--lib/std/resolve+posixy.myr6
-rw-r--r--lib/std/sort.myr2
-rw-r--r--mbld/build.myr2
-rw-r--r--mbld/deps.myr8
-rw-r--r--mbld/test.myr2
-rw-r--r--mi/dfcheck.c4
-rw-r--r--mi/match.c1
-rw-r--r--mk/c.mk2
-rw-r--r--parse/dump.c1
-rw-r--r--parse/gram.y9
-rw-r--r--parse/infer.c4
-rw-r--r--parse/lits.def1
-rw-r--r--parse/node.c10
-rw-r--r--parse/parse.h1
-rw-r--r--parse/specialize.c14
-rw-r--r--parse/tok.c1
-rw-r--r--parse/use.c2
28 files changed, 67 insertions, 39 deletions
diff --git a/6/blob.c b/6/blob.c
index a215e93..0be2af2 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -134,6 +134,7 @@ static size_t bloblit(Blob *seq, Htab *strtab, Node *v, Type *ty)
assert(v->type == Nlit);
sz = tysize(ty);
switch (v->lit.littype) {
+ case Lvoid: break;
case Lint: b(seq, mkblobi(intsz[sz], v->lit.intval)); break;
case Lbool: b(seq, mkblobi(Bti8, v->lit.boolval)); break;
case Lchr: b(seq, mkblobi(Bti32, v->lit.chrval)); break;
diff --git a/6/isel.c b/6/isel.c
index 356bdca..c9de7e1 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -133,6 +133,7 @@ static Loc *loc(Isel *s, Node *n)
case Olit:
v = n->expr.args[0];
switch (v->lit.littype) {
+ case Lvoid: l = NULL; break;
case Lchr: l = loclit(v->lit.chrval, mode(n)); break;
case Lbool: l = loclit(v->lit.boolval, mode(n)); break;
case Lint: l = loclit(v->lit.intval, mode(n)); break;
diff --git a/6/simp.c b/6/simp.c
index 03ad0b1..1f2aee3 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1328,6 +1328,8 @@ static Node *simpcall(Simp *s, Node *n, Node *dst)
for (i = 1; i < n->expr.nargs; i++) {
if (i < ft->nsub && tybase(ft->sub[i])->type == Tyvalist)
lappend(&args, &nargs, vatypeinfo(s, n));
+ if (tybase(exprtype(n->expr.args[i]))->type == Tyvoid)
+ continue;
lappend(&args, &nargs, rval(s, n->expr.args[i], NULL));
if (exprop(n->expr.args[i]) == Oaddr)
if (exprop(n->expr.args[i]->expr.args[0]) == Ovar)
@@ -1483,7 +1485,10 @@ static Node *rval(Simp *s, Node *n, Node *dst)
break;
case Olit:
switch (args[0]->lit.littype) {
- case Lchr: case Lbool: case Llbl:
+ case Lvoid:
+ case Lchr:
+ case Lbool:
+ case Llbl:
r = n;
break;
case Lint:
@@ -1535,7 +1540,8 @@ static Node *rval(Simp *s, Node *n, Node *dst)
append(s, mkexpr(n->loc, Oret, NULL));
break;
case Oasn:
- r = assign(s, args[0], args[1]);
+ if (tybase(exprtype(n))->type != Tyvoid)
+ r = assign(s, args[0], args[1]);
break;
case Ocall:
r = simpcall(s, n, dst);
diff --git a/lib/cryptohash/md5.myr b/lib/cryptohash/md5.myr
index 5f4b600..7aa15fd 100644
--- a/lib/cryptohash/md5.myr
+++ b/lib/cryptohash/md5.myr
@@ -45,7 +45,7 @@ const md5add = {st, data
std.slcp(st.tail[ntail:ntail + n], data[:n])
data = data[n:]
if n + ntail < 64
- ->
+ -> void
;;
step(st, st.tail[:])
;;
diff --git a/lib/cryptohash/sha1.myr b/lib/cryptohash/sha1.myr
index ecf0ec3..02b446c 100644
--- a/lib/cryptohash/sha1.myr
+++ b/lib/cryptohash/sha1.myr
@@ -46,7 +46,7 @@ const sha1add = {st, data
std.slcp(st.tail[ntail:ntail + n], data[:n])
data = data[n:]
if n + ntail < 64
- ->
+ -> void
;;
step(st, st.tail[:])
;;
diff --git a/lib/cryptohash/sha256.myr b/lib/cryptohash/sha256.myr
index 5939fa8..7c18278 100644
--- a/lib/cryptohash/sha256.myr
+++ b/lib/cryptohash/sha256.myr
@@ -51,7 +51,7 @@ const sha256add = {st, data
std.slcp(st.tail[ntail:ntail + n], data[:n])
data = data[n:]
if n + ntail < 64
- ->
+ -> void
;;
step(st.x[:], st.tail[:])
;;
@@ -117,7 +117,7 @@ const sha224add = {st, data
std.slcp(st.tail[ntail:ntail + n], data[:n])
data = data[n:]
if n + ntail < 64
- ->
+ -> void
;;
step(st.x[:], st.tail[:])
;;
diff --git a/lib/cryptohash/sha512.myr b/lib/cryptohash/sha512.myr
index e5d9543..a4ebb99 100644
--- a/lib/cryptohash/sha512.myr
+++ b/lib/cryptohash/sha512.myr
@@ -58,7 +58,7 @@ const sha512add = {st, data
std.slcp(st.tail[ntail:ntail+n], data[:n])
data = data[n:]
if n + ntail < 128
- ->
+ -> void
;;
step(st.x[:], st.tail[:])
;;
@@ -118,7 +118,7 @@ const sha384add = {st, data
std.slcp(st.tail[ntail:ntail+n], data[:n])
data = data[n:]
if n + ntail < 128
- ->
+ -> void
;;
step(st.x[:], st.tail[:])
;;
diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr
index 77d7814..3cee04b 100644
--- a/lib/regex/compile.myr
+++ b/lib/regex/compile.myr
@@ -189,7 +189,7 @@ const rtinsert = {rt, lo, hi
std.assert(lo.len == hi.len, "range sizes differ")
if lo.len == 0
rt.end = true
- ->
+ -> void
;;
n = rt.ranges.len
@@ -362,7 +362,7 @@ const append = {re, insn
/* instruction dump */
const idump = {re
if !re.debug
- ->
+ -> void
;;
for var i = 0; i < re.proglen; i++
std.put("{}:\t", i)
@@ -394,7 +394,7 @@ const idump = {re
/* AST dump */
const dump = {re, t, indent
if !re.debug
- ->
+ -> void
;;
for var i = 0; i < indent; i++
std.put(" ")
diff --git a/lib/regex/interp.myr b/lib/regex/interp.myr
index f8223eb..dafe582 100644
--- a/lib/regex/interp.myr
+++ b/lib/regex/interp.myr
@@ -229,7 +229,7 @@ const fork = {re, thr, ip, curip, mstart, mend
var thr
if ip == curip /* loop detection */
- ->
+ -> void
;;
thr = mkthread(re, ip)
thr.next = re.runq
diff --git a/lib/std/alloc.myr b/lib/std/alloc.myr
index 91e0440..d20c236 100644
--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -150,7 +150,7 @@ generic slfree = {sl
var head
if sl.len == 0
- ->
+ -> void
;;
checkhdr(sl castto(byte#))
diff --git a/lib/std/memops-impl.myr b/lib/std/memops-impl.myr
index 8c43453..568e8c0 100644
--- a/lib/std/memops-impl.myr
+++ b/lib/std/memops-impl.myr
@@ -16,7 +16,7 @@ const memblit = {dst, src, len
s = src[:len]
if da == sa
- ->
+ -> void
elif da < sa
for var i = 0; i < d.len; i++
d[i] = s[i]
diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr
index 38b9212..9b88d87 100644
--- a/lib/std/resolve+posixy.myr
+++ b/lib/std/resolve+posixy.myr
@@ -94,7 +94,7 @@ const loadhosts = {
match slurp(Hostfile)
| `Ok d: h = d
- | `Fail m: ->
+ | `Fail m: -> void
;;
lines = strsplit(h, "\n")
@@ -147,7 +147,7 @@ const addhosts = {addr, as, str
]
htput(hostmap, sldup(name), hinf)
| `None:
- ->
+ -> void
;;
;;
}
@@ -158,7 +158,7 @@ const loadresolv = {
match slurp(Resolvfile)
| `Ok d: h = d
- | `Fail m: ->
+ | `Fail m: -> void
;;
lines = strsplit(h, "\n")
diff --git a/lib/std/sort.myr b/lib/std/sort.myr
index dbf48d3..a51731d 100644
--- a/lib/std/sort.myr
+++ b/lib/std/sort.myr
@@ -54,7 +54,7 @@ generic siftdown = {sl, start, cmp
sl[s] = tmp
r = s
else
- ->
+ -> void
;;
;;
}
diff --git a/mbld/build.myr b/mbld/build.myr
index 5c5f758..5607c41 100644
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -66,7 +66,7 @@ const buildtarg = {b, targ
const addeps = {b, targ, depset
if std.hthas(depset, targ)
- ->
+ -> void
;;
std.htput(depset, targ, true)
diff --git a/mbld/deps.myr b/mbld/deps.myr
index a168c19..9835a4a 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -121,7 +121,7 @@ const dumpgraph = {dg
var keys
if !opt_debug
- ->
+ -> void
;;
keys = std.htkeys(dg.deps)
std.put("digraph dg {{\n")
@@ -137,7 +137,7 @@ const srcdeps = {b, ds, g, path, obj, usefile
var deps
if std.hthas(g.done, path)
- ->
+ -> void
;;
ds.depstk = std.slpush(ds.depstk, path)
@@ -185,7 +185,7 @@ const addusedep = {b, ds, g, f, usefile, line
if opt_debug
std.put("already loaded deps for {}\n", usefile)
;;
- ->
+ -> void
;;
match std.htget(g.input, usefile)
| `std.Some path:
@@ -314,7 +314,7 @@ const scrapelibs = {dg, lib, incs
var done
if std.hthas(dg.libs, lib)
- ->
+ -> void
;;
f = openlib(lib, incs)
diff --git a/mbld/test.myr b/mbld/test.myr
index 3d36c81..dadf8a7 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -72,7 +72,7 @@ const test = {b
;;
std.slfree(tests)
if tests.len == 0
- ->
+ -> void
;;
printfailed(failed)
diff --git a/mi/dfcheck.c b/mi/dfcheck.c
index 392c8dd..a785fc3 100644
--- a/mi/dfcheck.c
+++ b/mi/dfcheck.c
@@ -27,7 +27,7 @@ static void checkundef(Node *n, Reaching *r, Bitset *reach, Bitset *kill)
return;
for (j = 0; j < r->ndefs[did]; j++) {
t = tybase(exprtype(n));
- if (t->type == Tystruct || t->type == Tyunion || t->type == Tyarray || t->type == Tytuple)
+ if (t->type == Tystruct || t->type == Tyunion || t->type == Tyarray || t->type == Tytuple || t->type == Tyvoid)
continue;
if (bshas(kill, r->defs[did][j]))
continue;
@@ -35,7 +35,7 @@ static void checkundef(Node *n, Reaching *r, Bitset *reach, Bitset *kill)
continue;
def = nodes[r->defs[did][j]];
if (exprop(def) == Oundef)
- fatal(n, "%s used before definition [%d]", namestr(n->expr.args[0]), (int)did);
+ fatal(n, "%s used before definition", namestr(n->expr.args[0]));
}
} else {
switch (exprop(n)) {
diff --git a/mi/match.c b/mi/match.c
index f2c2c9c..bfca0a6 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -764,6 +764,7 @@ void dtreedumplit(FILE *fd, Dtree *dt, Node *n, size_t depth)
s = lblstr(dt->lbl);
switch (n->lit.littype) {
+ case Lvoid: findentf(fd, depth, "%s: Lvoid\n"); break;
case Lchr: findentf(fd, depth, "%s: Lchr %c\n", s, n->lit.chrval); break;
case Lbool: findentf(fd, depth, "%s: Lbool %s\n", s, n->lit.boolval ? "true" : "false"); break;
case Lint: findentf(fd, depth, "%s: Lint %llu\n", s, n->lit.intval); break;
diff --git a/mk/c.mk b/mk/c.mk
index e69a240..9792682 100644
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -9,7 +9,7 @@ _LIBINCPATHS=$(addprefix -I, $(dir $(DEPS))) $(_PCHDRS)
_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS)))) $(_PCLIBS)
# yeah, I should probably remove -Werror, but it's nice for developing alone.
-CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g
+CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g
CFLAGS += -MMD -MP -MF .deps/$(subst /,-,$*).d
LIB ?= $(INSTLIB)
diff --git a/parse/dump.c b/parse/dump.c
index 9651b60..c9eb139 100644
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -209,6 +209,7 @@ static void outnode(Node *n, FILE *fd, int depth)
break;
case Nlit:
switch (n->lit.littype) {
+ case Lvoid: fprintf(fd, " Lvoid\n"); break;
case Lchr: fprintf(fd, " Lchr %c\n", n->lit.chrval); break;
case Lbool: fprintf(fd, " Lbool %s\n", n->lit.boolval ? "true" : "false"); break;
case Lint: fprintf(fd, " Lint %llu\n", n->lit.intval); break;
diff --git a/parse/gram.y b/parse/gram.y
index 8aaa385..7e930ef 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -97,6 +97,7 @@ static void setupinit(Node *n);
%token<tok> Tfloatlit
%token<tok> Tchrlit
%token<tok> Tboollit
+%token<tok> Tvoidlit
%token<tok> Ttrait /* trait */
%token<tok> Timpl /* trait */
@@ -474,10 +475,11 @@ compoundtype
| type Tosqbrac Tcolon Tcsqbrac {$$ = mktyslice($2->loc, $1);}
| type Tosqbrac expr Tcsqbrac {$$ = mktyarray($2->loc, $1, $3);}
| type Tosqbrac Tellipsis Tcsqbrac {$$ = mktyarray($2->loc, $1, NULL);}
- | type Tderef {$$ = mktyptr($2->loc, $1);}
- | Tat Tident {$$ = mktyparam($1->loc, $2->id);}
- | name {$$ = mktyunres($1->loc, $1, NULL, 0);}
| name Toparen typelist Tcparen {$$ = mktyunres($1->loc, $1, $3.types, $3.ntypes);}
+ | type Tderef {$$ = mktyptr($2->loc, $1);}
+ | Tat Tident {$$ = mktyparam($1->loc, $2->id);}
+ | Tvoidlit {$$ = mktyunres($1->loc, mkname($1->loc, $1->id), NULL, 0);}
+ | name {$$ = mktyunres($1->loc, $1, NULL, 0);}
;
functype: Toparen funcsig Tcparen {$$ = $2;}
@@ -748,6 +750,7 @@ littok : Tstrlit {$$ = mkstr($1->loc, $1->strval);}
| Tchrlit {$$ = mkchar($1->loc, $1->chrval);}
| Tfloatlit {$$ = mkfloat($1->loc, $1->fltval);}
| Tboollit {$$ = mkbool($1->loc, !strcmp($1->id, "true"));}
+ | Tvoidlit {$$ = mkvoid($1->loc);}
| Tintlit {
$$ = mkint($1->loc, $1->intval);
if ($1->inttype)
diff --git a/parse/infer.c b/parse/infer.c
index 3b5e413..6894a1c 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -526,6 +526,7 @@ static Type *littype(Node *n)
t = NULL;
if (!n->lit.type) {
switch (n->lit.littype) {
+ case Lvoid: t = mktype(n->loc, Tyvoid); break;
case Lchr: t = mktype(n->loc, Tychar); break;
case Lbool: t = mktype(n->loc, Tybool); break;
case Lint: t = mktylike(n->loc, Tyint); break;
@@ -999,9 +1000,6 @@ static void unifycall(Inferstate *st, Node *n)
fatal(n, "calling uncallable type %s", tystr(ft));
}
/* first arg: function itself */
- for (i = 1; i < n->expr.nargs; i++)
- if (exprtype(n->expr.args[i])->type == Tyvoid)
- fatal(n, "void passed where value expected, near %s", ctxstr(st, n));
for (i = 1; i < n->expr.nargs; i++) {
if (i == ft->nsub)
fatal(n, "%s arity mismatch (expected %zd args, got %zd)",
diff --git a/parse/lits.def b/parse/lits.def
index 2e5342f..53725ff 100644
--- a/parse/lits.def
+++ b/parse/lits.def
@@ -5,3 +5,4 @@ L(Lflt)
L(Lstr)
L(Lfunc)
L(Llbl)
+L(Lvoid)
diff --git a/parse/node.c b/parse/node.c
index 62be764..8d0decf 100644
--- a/parse/node.c
+++ b/parse/node.c
@@ -374,6 +374,15 @@ Node *mkbool(Srcloc loc, int val)
return n;
}
+Node *mkvoid(Srcloc loc)
+{
+ Node *n;
+
+ n = mknode(loc, Nlit);
+ n->lit.littype = Lvoid;
+ return n;
+}
+
char *declname(Node *n)
{
Node *name;
@@ -413,6 +422,7 @@ int liteq(Node *a, Node *b)
if (!tyeq(a->lit.type, b->lit.type))
return 0;
switch (a->lit.littype) {
+ case Lvoid: return 1;
case Lchr: return a->lit.chrval == b->lit.chrval;
case Lbool: return a->lit.boolval == b->lit.boolval;
case Lint: return a->lit.intval == b->lit.intval;
diff --git a/parse/parse.h b/parse/parse.h
index ab71500..f94635e 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -563,6 +563,7 @@ Node *mkimplstmt(Srcloc l, Node *name, Type *type, Node **impls, size_t nimpls);
Node *mkintlit(Srcloc l, uvlong val);
Node *mkidxinit(Srcloc l, Node *idx, Node *init);
+Node *mkvoid(Srcloc loc);
Node *mkbool(Srcloc l, int val);
Node *mkint(Srcloc l, uint64_t val);
Node *mkchar(Srcloc l, uint32_t val);
diff --git a/parse/specialize.c b/parse/specialize.c
index 1414119..7a9eb70 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -180,12 +180,13 @@ static void fixup(Node *n)
case Nlit:
switch (n->lit.littype) {
case Lfunc: fixup(n->lit.fnval); break;
- case Lchr:
- case Lint:
- case Lflt:
- case Lstr:
- case Llbl:
- case Lbool: break;
+ case Lvoid: break;
+ case Lchr: break;
+ case Lint: break;
+ case Lflt: break;
+ case Lstr: break;
+ case Llbl: break;
+ case Lbool: break;
}
break;
case Nifstmt:
@@ -273,6 +274,7 @@ static Node *specializenode(Node *n, Htab *tsmap)
r->lit.littype = n->lit.littype;
r->lit.type = tysubst(n->expr.type, tsmap);
switch (n->lit.littype) {
+ case Lvoid: break;
case Lchr: r->lit.chrval = n->lit.chrval; break;
case Lint: r->lit.intval = n->lit.intval; break;
case Lflt: r->lit.fltval = n->lit.fltval; break;
diff --git a/parse/tok.c b/parse/tok.c
index 068af8e..fd3597c 100644
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -191,6 +191,7 @@ static int kwd(char *s)
{"union", Tunion},
{"use", Tuse},
{"var", Tvar},
+ {"void", Tvoidlit},
{"while", Twhile},
};
diff --git a/parse/use.c b/parse/use.c
index 88ac64a..5c5e229 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -469,6 +469,7 @@ static void pickle(FILE *fd, Node *n)
wrtype(fd, n->lit.type);
wrint(fd, n->lit.nelt);
switch (n->lit.littype) {
+ case Lvoid: break;
case Lchr: wrint(fd, n->lit.chrval); break;
case Lint: wrint(fd, n->lit.intval); break;
case Lflt: wrflt(fd, n->lit.fltval); break;
@@ -598,6 +599,7 @@ static Node *unpickle(FILE *fd)
rdtype(fd, &n->lit.type);
n->lit.nelt = rdint(fd);
switch (n->lit.littype) {
+ case Lvoid: break;
case Lchr: n->lit.chrval = rdint(fd); break;
case Lint: n->lit.intval = rdint(fd); break;
case Lflt: n->lit.fltval = rdflt(fd); break;