shithub: scc

Download patch

ref: 1f4d772a7ff6987171acc1c6c5922123b764c110
parent: ef6ebfdd2c77c82be5ed3e50e13031d05598f905
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jul 4 16:17:16 EDT 2013

Forbid 'signed' or 'unsigned' with floating types

It is a non sense signess modifier in floating types.

--- a/decl.c
+++ b/decl.c
@@ -88,10 +88,17 @@
 				error("duplicated '%s'", yytext);
 			if (sign)
 				error("both 'signed' and 'unsigned' in declaration specifiers");
+			switch (type) {
+			case FLOAT: case DOUBLE: case LDOUBLE:
+				goto float_sign;
+			}
 			sign = yytoken;
 			break;
-		case VOID:   case CHAR:   case SHORT:  case INT:
-		case FLOAT:  case DOUBLE: case LONG:   case BOOL:
+		case FLOAT: case DOUBLE:
+			if (sign)
+				goto float_sign;
+		case VOID:   case CHAR:   case SHORT:
+		case INT:    case LONG:   case BOOL:
 			cp->type = btype(cp->type, yytoken);
 			break;
 		case STRUCT:    /* TODO */
@@ -103,6 +110,8 @@
 			return n;
 		}
 	}
+float_sign:
+	error("floating types cannot be signed or unsigned");
 }
 
 static void
--