shithub: scc

Download patch

ref: 9b5f080eb2ecc01e6aebe3d900c893519b0cc402
parent: e7d61b828ba8ace866a5cffb1cfb5bffae8434e6
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Aug 4 05:24:06 EDT 2015

Remove default int without type modifier, storage, qualifier

This logic was creating some problems in typenames, so it is
better remove from the datapath of specifier and add it later
directly in external declarations (or don't add it again).

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -188,9 +188,9 @@
 specifier(unsigned *sclass)
 {
 	Type *tp = NULL;
-	unsigned qlf, sign, type, cls, size;
+	unsigned spec, qlf, sign, type, cls, size;
 
-	qlf = sign = type = cls = size = 0;
+	spec = qlf = sign = type = cls = size = 0;
 
 	for (;;) {
 		unsigned *p;
@@ -258,12 +258,13 @@
 		} else {
 			next();
 		}
+		spec = 1;
 	}
 
 return_type:
 	if (sclass)
 		*sclass = cls;
-	if (!tp)
+	if (!tp && spec)
 		tp = ctype(type, sign, size);
 	return tp;
 
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -222,9 +222,7 @@
 			goto invalid_type;
 		return booltype;
 	case 0:
-		if (!sign && !size) {
-			warn("type defaults to 'int' in declaration");
-		}
+		warn("type defaults to 'int' in declaration");
 		/* fallthrough */
 	case INT:
 		switch (size) {