shithub: scc

Download patch

ref: 5ac24b9b6ee631848b5a2cc893ba7381ccf9c87f
parent: d00c0a144ba4565dfc73b8429457aba03faf2264
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Sep 15 08:34:04 EDT 2015

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.

--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -173,6 +173,7 @@
 	CONST      =       1,      /* type qualifier tokens are used as flags */
 	RESTRICT   =       2,
 	VOLATILE   =       4,
+	INLINE     =       8,
 	TQUALIFIER =     128,
 	TYPE,
 	IDEN,
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -26,6 +26,7 @@
 struct decl {
 	unsigned ns;
 	int sclass;
+	int qualifier;
 	Symbol *sym;
 	Symbol **pars;
 	Type *type;
@@ -259,7 +260,7 @@
 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 @@
 	}
 
 return_type:
-	if (sclass)
-		*sclass = cls;
+	*sclass = cls;
+	*qualifier = qlf;
 	if (!tp) {
 		if (spec) {
 			tp = ctype(type, sign, size);
@@ -684,7 +685,7 @@
 
 	dcl.ns = ns;
 	dcl.parent = parent;
-	base = specifier(&dcl.sclass);
+	base = specifier(&dcl.sclass, &dcl.qualifier);
 
 	do {
 		stack.nr = 0;
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -321,6 +321,7 @@
 		{"for", FOR, FOR},
 		{"goto", GOTO, GOTO},
 		{"if", IF, IF},
+		{"inline", TQUALIFIER, INLINE},
 		{"int", TYPE, INT},
 		{"long", TYPE, LONG},
 		{"register", SCLASS, REGISTER},
--