shithub: scc

Download patch

ref: c20c165fc5a69576846c832a43d044a157a35561
parent: 9cba57490676e913c7afd25c62cd9e8acc7ad126
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 19 08:10:47 EST 2016

[cc1] Add fake version of __builtin_va_list

This is a bultin type that is needed for libc implementations
because they cannot know the type used by the compilers,
and making a if-else if for all the compiler is a really
bad idea.

--- a/cc1/arch/amd64-sysv/arch.c
+++ b/cc1/arch/amd64-sysv/arch.c
@@ -182,6 +182,13 @@
 		.align = 8,
 		.n.rank = RANK_LONG,
 	},
+	{       /* 20 = va_list_type */
+		.op = PTR,
+		.letter = L_POINTER,
+		.prop = TDEFINED,
+		.size = 8,
+		.align = 8,
+	}
 };
 
 Type *voidtype = &types[0], *pvoidtype = &types[1],
@@ -194,7 +201,8 @@
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
-     *ellipsistype = &types[18];
+     *ellipsistype = &types[18],
+     *va_list_type = &types[20];
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
--- a/cc1/arch/i386-sysv/arch.c
+++ b/cc1/arch/i386-sysv/arch.c
@@ -181,6 +181,13 @@
 		.align = 4,
 		.n.rank = RANK_INT,
 	},
+	{       /* 20 = va_list_type */
+		.op = PTR,
+		.letter = L_POINTER,
+		.prop = TDEFINED,
+		.size = 8,
+		.align = 8,
+	}
 };
 
 
@@ -194,7 +201,9 @@
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
-     *ellipsistype = &types[18];
+     *ellipsistype = &types[18],
+     *va_list_type = &types[20];
+
 
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
--- a/cc1/arch/qbe/arch.c
+++ b/cc1/arch/qbe/arch.c
@@ -182,6 +182,13 @@
 		.align = 8,
 		.n.rank = RANK_LONG,
 	},
+	{       /* 20 = va_list_type */
+		.op = PTR,
+		.letter = L_POINTER,
+		.prop = TDEFINED,
+		.size = 8,
+		.align = 8,
+	}
 };
 
 Type *voidtype = &types[0], *pvoidtype = &types[1],
@@ -194,7 +201,8 @@
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
-     *ellipsistype = &types[18];
+     *ellipsistype = &types[18],
+     *va_list_type = &types[20];
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
--- a/cc1/arch/z80/arch.c
+++ b/cc1/arch/z80/arch.c
@@ -182,6 +182,13 @@
 		.align = 1,
 		.n.rank = RANK_SHORT,
 	},
+	{       /* 20 = va_list_type */
+		.op = PTR,
+		.letter = L_POINTER,
+		.prop = TDEFINED,
+		.size = 8,
+		.align = 8,
+	}
 };
 
 Type *voidtype = &types[0], *pvoidtype = &types[1],
@@ -194,7 +201,9 @@
      *floattype = &types[14], *doubletype = &types[15],
      *ldoubletype = &types[16],
      *sizettype = &types[17], *pdifftype = &types[19],
-     *ellipsistype = &types[18];
+     *ellipsistype = &types[18],
+     *va_list_type = &types[20];
+
 
 static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
               dummy1 = {.u.i = 1, .type = &types[9]};
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -153,6 +153,7 @@
 	FLOAT,
 	INT,
 	BOOL,
+	VA_LIST,
 	STRUCT,
 	UNION,
 	CHAR,
@@ -451,4 +452,4 @@
             *longtype,    *ulongtype,
             *ullongtype,  *llongtype,
             *floattype,   *doubletype,  *ldoubletype,
-            *ellipsistype;
+            *ellipsistype, *va_list_type;
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -405,6 +405,7 @@
 				dcl = structdcl;
 				p = &type;
 				break;
+			case VA_LIST:
 			case VOID:
 			case BOOL:
 			case CHAR:
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -46,6 +46,7 @@
 		{"auto", SCLASS, AUTO},
 		{"break", BREAK, BREAK},
 		{"_Bool", TYPE, BOOL},
+		{"__builtin_va_list", TYPE, VA_LIST},
 		{"case", CASE, CASE},
 		{"char", TYPE, CHAR},
 		{"const", TQUALIFIER, CONST},
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -122,6 +122,10 @@
 			return uchartype;
 		}
 		break;
+	case VA_LIST:
+		if (size || sign)
+			goto invalid_type;
+		return va_list_type;
 	case VOID:
 		if (size || sign)
 			goto invalid_type;