scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit cdbda619738223f411c13151369df33508bb9716
parent 0e38613504c7711310c22403a692bef825f00dc8
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  5 Aug 2014 19:02:47 +0200

Use better indentation in ctype()

The indentation of ctype was a bit ugly and there was not check
of incorret parameters.

Diffstat:
cc1/types.c | 43+++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/cc1/types.c b/cc1/types.c @@ -1,5 +1,6 @@ #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> @@ -121,23 +122,37 @@ ctype(int8_t type, int8_t sign, int8_t size) type = FLOAT, size += LONG; switch (type) { - case CHAR: if (sign == 0) - return chartype; - return (sign == UNSIGNED) ? uchartype : schartype; - case VOID: return voidtype; - case BOOL: return booltype; - case INT: switch (size) { - case 0: return (sign == UNSIGNED) ? uinttype : inttype; - case SHORT: return (sign == UNSIGNED) ? ushortype : shortype; - case LONG: return (sign == UNSIGNED) ? ulongtype : longtype; - case LONG+LONG: return (sign == UNSIGNED) ? ullongtype : llongtype; + case CHAR: + if (sign == 0) + return chartype; + return (sign == UNSIGNED) ? uchartype : schartype; + case VOID: + return voidtype; + case BOOL: + return booltype; + case INT: + switch (size) { + case 0: + return (sign == UNSIGNED) ? uinttype : inttype; + case SHORT: + return (sign == UNSIGNED) ? ushortype : shortype; + case LONG: + return (sign == UNSIGNED) ? ulongtype : longtype; + case LONG+LONG: + return (sign == UNSIGNED) ? ullongtype : llongtype; } - case FLOAT: switch (size) { - case 0: return floattype; - case LONG: return doubletype; - case LONG+LONG: return ldoubletype; + case FLOAT: + switch (size) { + case 0: + return floattype; + case LONG: + return doubletype; + case LONG+LONG: + return ldoubletype; } } + fputs("internal type error, aborting\n", stderr); + abort(); } Type *