diff options
author | Ori Bernstein <ori@eigenstate.org> | 2016-09-08 21:28:03 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2016-09-08 21:28:03 -0700 |
commit | f536dec7915b6285916c7281ac992c24fa1ccf32 (patch) | |
tree | 93af8d91ed0cc5c8dc138145fdbc8dfcd052fee4 /6 | |
parent | d5c4a8280725d9430ba07530e5be0f08f29be936 (diff) | |
download | mc-f536dec7915b6285916c7281ac992c24fa1ccf32.tar.gz |
Allow any type to be cast to its base type.
Diffstat (limited to '6')
-rw-r--r-- | 6/simp.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -543,6 +543,12 @@ static Node *simpcast(Simp *s, Node *val, Type *to) Type *t; r = NULL; + t = tybase(exprtype(val)); + if (tyeq(tybase(to), tybase(t))) { + r = rval(s, val, NULL); + r->expr.type = to; + return r; + } /* do the type conversion */ switch (tybase(to)->type) { case Tybool: @@ -550,7 +556,6 @@ static Node *simpcast(Simp *s, Node *val, Type *to) case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64: case Tyint: case Tyuint: case Tychar: case Tybyte: case Typtr: - t = tybase(exprtype(val)); switch (t->type) { /* ptr -> slice conversion is disallowed */ case Tyslice: @@ -590,7 +595,6 @@ static Node *simpcast(Simp *s, Node *val, Type *to) } break; case Tyflt32: case Tyflt64: - t = tybase(exprtype(val)); switch (t->type) { case Tyint8: case Tyint16: case Tyint32: case Tyint64: case Tyuint8: case Tyuint16: case Tyuint32: case Tyuint64: |