scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 5ac24b9b6ee631848b5a2cc893ba7381ccf9c87f
parent d00c0a144ba4565dfc73b8429457aba03faf2264
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 15 Sep 2015 12:34:04 +0200

Add inline keyword

This keyword must be used only in functions. At this moment is is
accepted, but it is not done the semantic analysis.

Diffstat:
Mcc1/cc1.h | 1+
Mcc1/decl.c | 9+++++----
Mcc1/symbol.c | 1+
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -173,6 +173,7 @@ enum tokens { CONST = 1, /* type qualifier tokens are used as flags */ RESTRICT = 2, VOLATILE = 4, + INLINE = 8, TQUALIFIER = 128, TYPE, IDEN, diff --git a/cc1/decl.c b/cc1/decl.c @@ -26,6 +26,7 @@ struct declarators { struct decl { unsigned ns; int sclass; + int qualifier; Symbol *sym; Symbol **pars; Type *type; @@ -259,7 +260,7 @@ declarator(struct declarators *dp, unsigned ns) static Type *structdcl(void), *enumdcl(void); static Type * -specifier(int *sclass) +specifier(int *sclass, int *qualifier) { Type *tp = NULL; int spec, qlf, sign, type, cls, size, mask; @@ -336,8 +337,8 @@ specifier(int *sclass) } return_type: - if (sclass) - *sclass = cls; + *sclass = cls; + *qualifier = qlf; if (!tp) { if (spec) { tp = ctype(type, sign, size); @@ -684,7 +685,7 @@ dodcl(int rep, Symbol *(*fun)(struct decl *), unsigned ns, Type *parent) dcl.ns = ns; dcl.parent = parent; - base = specifier(&dcl.sclass); + base = specifier(&dcl.sclass, &dcl.qualifier); do { stack.nr = 0; diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -321,6 +321,7 @@ ikeywords(void) {"for", FOR, FOR}, {"goto", GOTO, GOTO}, {"if", IF, IF}, + {"inline", TQUALIFIER, INLINE}, {"int", TYPE, INT}, {"long", TYPE, LONG}, {"register", SCLASS, REGISTER},