From c0db8eafdfe5b49191451104d207f8cf61e1c52a Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Thu, 11 Feb 2016 20:14:08 -0500 Subject: patch minic for new comparisons This solved one pending bug: comparisons of long variables are now compiled properly. A bug for comparisons < and <= of pointers remain, it is related to signedness, not width. This can be easily fixed by the reader! --- minic/minic.y | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'minic') diff --git a/minic/minic.y b/minic/minic.y index 0abef05..06ef2d6 100644 --- a/minic/minic.y +++ b/minic/minic.y @@ -312,13 +312,14 @@ expr(Node *n) ['/'] = "div", ['%'] = "rem", ['&'] = "and", - ['<'] = "cslt", /* meeeeh, careful with pointers/long */ + ['<'] = "cslt", /* meeeeh, wrong for pointers! */ ['l'] = "csle", ['e'] = "ceq", ['n'] = "cne", }; Symb sr, s0, s1, sl; int o, l; + char ty[2]; sr.t = Tmp; sr.u.n = tmp++; @@ -411,12 +412,15 @@ expr(Node *n) o = n->op; Binop: sr.ctyp = prom(o, &s0, &s1); - if (strchr("neop)) + if (strchr("neop)) { + sprintf(ty, "%c", irtyp(sr.ctyp)); sr.ctyp = INT; + } else + strcpy(ty, ""); fprintf(of, "\t"); psymb(sr); fprintf(of, " =%c", irtyp(sr.ctyp)); - fprintf(of, " %s ", otoa[o]); + fprintf(of, " %s%s ", otoa[o], ty); Args: psymb(s0); fprintf(of, ", "); -- cgit 1.4.1