ref: deac7e2b9839a79018051cfbad61ce98014ca5ed
parent: 832ea42180bd2b051dffcce298d785fa246e86b2
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Dec 1 04:25:58 EST 2016
[cc1] Call to typesize() in all the defined types Typesize() fills the size and aligment fields of new types, but it cannot be called until the type is defined. At this point it was called only for structs and enumerations, but it must be called for any defined type.
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -554,6 +554,7 @@
if (tp->prop & TDEFINED)
errorp("redefinition of enumeration '%s'", tagsym->name);
tp->prop |= TDEFINED;
+ typesize(tp);
namespace = NS_IDEN;
/* TODO: check incorrect values in val */
--- a/cc1/init.c
+++ b/cc1/init.c
@@ -121,6 +121,7 @@
if (!(tp->prop & TDEFINED)) {
tp->prop |= TDEFINED;
tp->n.elem = len+1;
+ typesize(tp);
} else if (tp->n.elem < len) {
warn("initializer-string for array of chars is too long");
}
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -263,6 +263,7 @@
case UNION: c = L_UNION; break;
}
+ memset(&type, 0, sizeof(type));
type.type = tp;
type.op = op;
type.prop = k_r ? TK_R : 0;
@@ -306,6 +307,8 @@
}
}
+ if (type.prop & TDEFINED)
+ typesize(&type);
bp = xmalloc(sizeof(*bp));
*bp = type;
bp->id = newid();