scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit cd19be49d9666dc294084fbe4dcb5ff613aa2d56
parent 42b233b62500a046fc04180f067c48af7030b127
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 21 Apr 2015 13:17:28 +0200

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.

Diffstat:
cc1/cc1.h | 12+-----------
cc1/error.c | 6++++--
cc1/expr.c | 6+++---
cc1/lex.c | 2+-
cc1/main.c | 2+-
cc1/stmt.c | 4++--
cc1/types.c | 3+--
7 files changed, 13 insertions(+), 22 deletions(-)

diff --git 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 */ diff --git a/cc1/error.c b/cc1/error.c @@ -25,11 +25,13 @@ warn_helper(signed char flag, const char *fmt, va_list va) } 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); } diff --git a/cc1/expr.c b/cc1/expr.c @@ -31,8 +31,9 @@ promote(Node *np) { 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 @@ pcompare(char op, Node *np1, Node *np2) 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"); diff --git a/cc1/lex.c b/cc1/lex.c @@ -125,7 +125,7 @@ repeat: goto repeat; break; default: - warn(1, "unknown escape sequence"); + warn("unknown escape sequence"); return s; } diff --git 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[]) diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -156,11 +156,11 @@ Return(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) 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"); } diff --git a/cc1/types.c b/cc1/types.c @@ -155,8 +155,7 @@ ctype(int8_t type, int8_t sign, int8_t size) 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: