scc

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

commit 1f4d772a7ff6987171acc1c6c5922123b764c110
parent ef6ebfdd2c77c82be5ed3e50e13031d05598f905
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu,  4 Jul 2013 20:17:16 +0200

Forbid 'signed' or 'unsigned' with floating types

It is a non sense signess modifier in floating types.

Diffstat:
Mdecl.c | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/decl.c b/decl.c @@ -88,10 +88,17 @@ spec(register struct ctype *cp) 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 @@ spec(register struct ctype *cp) return n; } } +float_sign: + error("floating types cannot be signed or unsigned"); } static void