shithub: scc

Download patch

ref: 9c6d70a63e38b5c92ae26e0e9ff19b585f7ff0e1
parent: b20db931867df763206ca9856fc0ec2a34af54cb
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Aug 11 19:01:44 EDT 2014

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.

--- a/cc1/code.c
+++ b/cc1/code.c
@@ -46,8 +46,8 @@
 	[OADDR] = "a",
 	[ONEG] = "_",
 	[OCPL] = "~",
-	[OAND] = "m",
-	[OOR] = "s",
+	[OAND] = "y",
+	[OOR] = "o",
 	[OCOMMA] = ","
 };
 
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -535,8 +535,8 @@
 		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();
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -84,6 +84,9 @@
 #define OLE       '['
 #define OEQ       '='
 #define ONE       '!'
+#define OOR       'o'
+#define OAND      'y'
+#define ONEG      '_'
 
 extern void error(unsigned nerror, ...);
 extern void genaddable(Node *list[]);