scc

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

commit 5ae4a720c0f1a1b07cbb3236903a08b71fe33e00
parent bcbe85359f6a31024317c356bcfc19ea63117ca0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Jul 2013 08:24:39 +0200

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).

Diffstat:
Mdecl.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/decl.c b/decl.c @@ -91,19 +91,18 @@ spec(void) 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(); 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 @@ spec(void) return tp; } } -float_sign: - error("floating types cannot be signed or unsigned"); +invalid_sign: + error("invalid sign modifier"); } static void