commit 481870312e7a7e2389e138a97698811977541970
parent 668cf8197fe0249df975adfae16d2df56f2cc696
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 19 Dec 2016 13:10:47 +0100
[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.
Diffstat:
8 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/cc1/arch/amd64-sysv/arch.c b/cc1/arch/amd64-sysv/arch.c
@@ -182,6 +182,13 @@ static Type types[] = {
.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 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
*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]};
diff --git a/cc1/arch/i386-sysv/arch.c b/cc1/arch/i386-sysv/arch.c
@@ -181,6 +181,13 @@ static Type types[] = {
.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 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
*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]},
diff --git a/cc1/arch/qbe/arch.c b/cc1/arch/qbe/arch.c
@@ -182,6 +182,13 @@ static Type types[] = {
.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 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
*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]};
diff --git a/cc1/arch/z80/arch.c b/cc1/arch/z80/arch.c
@@ -182,6 +182,13 @@ static Type types[] = {
.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 @@ Type *voidtype = &types[0], *pvoidtype = &types[1],
*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]};
diff --git a/cc1/cc1.h b/cc1/cc1.h
@@ -153,6 +153,7 @@ enum tokens {
FLOAT,
INT,
BOOL,
+ VA_LIST,
STRUCT,
UNION,
CHAR,
@@ -451,4 +452,4 @@ extern Type *voidtype, *pvoidtype, *booltype,
*longtype, *ulongtype,
*ullongtype, *llongtype,
*floattype, *doubletype, *ldoubletype,
- *ellipsistype;
+ *ellipsistype, *va_list_type;
diff --git a/cc1/decl.c b/cc1/decl.c
@@ -405,6 +405,7 @@ specifier(int *sclass, int *qualifier)
dcl = structdcl;
p = &type;
break;
+ case VA_LIST:
case VOID:
case BOOL:
case CHAR:
diff --git a/cc1/lex.c b/cc1/lex.c
@@ -46,6 +46,7 @@ ilex(void)
{"auto", SCLASS, AUTO},
{"break", BREAK, BREAK},
{"_Bool", TYPE, BOOL},
+ {"__builtin_va_list", TYPE, VA_LIST},
{"case", CASE, CASE},
{"char", TYPE, CHAR},
{"const", TQUALIFIER, CONST},
diff --git a/cc1/types.c b/cc1/types.c
@@ -122,6 +122,10 @@ ctype(unsigned type, unsigned sign, unsigned size)
return uchartype;
}
break;
+ case VA_LIST:
+ if (size || sign)
+ goto invalid_type;
+ return va_list_type;
case VOID:
if (size || sign)
goto invalid_type;