shithub: scc

Download patch

ref: cdbda619738223f411c13151369df33508bb9716
parent: 0e38613504c7711310c22403a692bef825f00dc8
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 5 15:02:47 EDT 2014

Use better indentation in ctype()

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

--- 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 @@
 		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 *