shithub: scc

Download patch

ref: cd19be49d9666dc294084fbe4dcb5ff613aa2d56
parent: 42b233b62500a046fc04180f067c48af7030b127
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Apr 21 09:17:28 EDT 2015

Remove user_opt struct

This struct was a bit stupid, and in fact it was not used at all,
so the best option is to remove it and to use one variable for
every field of the structure.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -1,17 +1,7 @@
 
 
-struct user_opt {
-	unsigned char implicit;
-	unsigned char mixdcls;
-	unsigned char npromote;
-	unsigned char useless;
-	unsigned char charsign;
-	unsigned char pcompare;
-};
-
-extern struct user_opt options;
 extern void error(const char *fmt, ...);
-extern void warn(signed char flag, const char *fmt, ...);
+extern void warn(const char *fmt, ...);
 extern void unexpected(void);
 
 /* definitions of types */
--- a/cc1/error.c
+++ b/cc1/error.c
@@ -25,11 +25,13 @@
 }
 
 void
-warn(signed char flag, const char *fmt, ...)
+warn(const char *fmt, ...)
 {
+	extern uint8_t warnings;
+
 	va_list va;
 	va_start(va, fmt);
-	warn_helper(flag, fmt, va);
+	warn_helper(warnings, fmt, va);
 	va_end(va);
 }
 
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -31,8 +31,9 @@
 {
 	Type *tp;
 	uint8_t r;
+	extern uint8_t npromote;
 
-	if (options.npromote)
+	if (npromote)
 		return np;
 	tp = np->type;
 	r = tp->n.rank;
@@ -243,8 +244,7 @@
 		break;
 	case PTR:
 		if (np1->type != np2->type)
-			warn(options.pcompare,
-			     "comparision between different pointer types");
+			warn("comparision between different pointer types");
 		break;
 	default:
 		error("incompatibles type in comparision");
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -125,7 +125,7 @@
 			goto repeat;
 		break;
 	default:
-		warn(1, "unknown escape sequence");
+		warn("unknown escape sequence");
 		return s;
 	}
 
--- a/cc1/main.c
+++ b/cc1/main.c
@@ -8,7 +8,7 @@
 extern void init_keywords(void),
 	open_file(const char *file),  init_expr(void);
 
-struct user_opt options;
+uint8_t npromote, warnings;
 
 int
 main(int argc, char *argv[])
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -156,11 +156,11 @@
 	expect(';');
 	if (!np) {
 		if (tp != voidtype)
-			warn(1, "function returning non void returns no value");
+			warn("function returning non void returns no value");
 		tp = voidtype;
 	} else if (np->type != tp) {
 		if (tp == voidtype)
-			warn(1, "function returning void returns a value");
+			warn("function returning void returns a value");
 		else if ((np = convert(np, tp, 0)) == NULL)
 			error("incorrect type in return");
 	}
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -155,8 +155,7 @@
 		return booltype;
 	case 0:
 		if (!sign && !size) {
-			warn(options.implicit,
-			     "type defaults to 'int' in declaration");
+			warn("type defaults to 'int' in declaration");
 		}
 		/* fallthrough */
 	case INT: