shithub: scc

Download patch

ref: 5ae4a720c0f1a1b07cbb3236903a08b71fe33e00
parent: bcbe85359f6a31024317c356bcfc19ea63117ca0
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Jul 5 04:24:39 EDT 2013

Forbid sign modifier in bool type

Bool type can not be signed or unsigned. It represents the
smaller data type which can hold a bit (usually a unsigned char).

--- a/decl.c
+++ b/decl.c
@@ -91,8 +91,8 @@
 			if (sign)
 				error("both 'signed' and 'unsigned' in declaration specifiers");
 			switch (type) {
-			case FLOAT: case DOUBLE: case LDOUBLE:
-				goto float_sign;
+			case FLOAT: case DOUBLE: case LDOUBLE: case BOOL:
+				goto invalid_sign;
 			}
 			if (!tp)
 				tp = newctype();
@@ -99,11 +99,10 @@
 			if ((type = sign = yytoken) == UNSIGNED)
 				tp->c_unsigned = 1;
 			break;
-		case FLOAT: case DOUBLE:
+		case FLOAT: case DOUBLE: case BOOL:
 			if (sign)
-				goto float_sign;
-		case VOID:   case CHAR:   case SHORT:
-		case INT:    case LONG:   case BOOL:
+				goto invalid_sign;
+		case VOID: case CHAR: case SHORT: case INT: case LONG:
 			tp = btype(tp, yytoken);
 			type = tp->type;
 			break;
@@ -128,8 +127,8 @@
 			return tp;
 		}
 	}
-float_sign:
-	error("floating types cannot be signed or unsigned");
+invalid_sign:
+	error("invalid sign modifier");
 }
 
 static void
--