scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 9c6d70a63e38b5c92ae26e0e9ff19b585f7ff0e1
parent b20db931867df763206ca9856fc0ec2a34af54cb
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 11 Aug 2014 23:01:44 +0200

Fix generation of intermediate code for unary - and ~

These codes were generating incorrect codes, because - was
generating code for substraction and ~ was generating code for
negation.

Diffstat:
Mcc1/code.c | 4++--
Mcc1/expr.c | 4++--
Mcc2/cc2.h | 3+++
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -46,8 +46,8 @@ char *opcodes[] = { [OADDR] = "a", [ONEG] = "_", [OCPL] = "~", - [OAND] = "m", - [OOR] = "s", + [OAND] = "y", + [OOR] = "o", [OCOMMA] = "," }; diff --git a/cc1/expr.c b/cc1/expr.c @@ -535,8 +535,8 @@ unary(void) return incdec(unary(), op); case '!': op = 0; fun = negation; break; case '+': op = OADD; fun = integeruop; break; - case '-': op = OSUB; fun = integeruop; break; - case '~': op = ONEG; fun = integeruop; break; + case '-': op = ONEG; fun = integeruop; break; + case '~': op = OCPL; fun = integeruop; break; case '&': op = OADDR; fun = address; break; case '*': op = OPTR; fun = content; break; default: return postfix(); diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -84,6 +84,9 @@ enum nerrors { #define OLE '[' #define OEQ '=' #define ONE '!' +#define OOR 'o' +#define OAND 'y' +#define ONEG '_' extern void error(unsigned nerror, ...); extern void genaddable(Node *list[]);