[hackers] [scc] [cc1] Call to typesize() in all the defined types || Roberto E. Vargas Caballero
commit b140b6aa1a408ef2e6693ed093d82432583a3be5
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Dec 1 09:25:58 2016 +0100
Commit: damia <alejandro.berna_AT_sener.es>
CommitDate: Thu Dec 1 09:38:07 2016 +0100
[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.
diff --git a/cc1/decl.c b/cc1/decl.c
index 6397ca0..7180a30 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -554,6 +554,7 @@ enumdcl(void)
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 */
diff --git a/cc1/init.c b/cc1/init.c
index 1433453..854fa4f 100644
--- a/cc1/init.c
+++ b/cc1/init.c
_AT_@ -121,6 +121,7 @@ initialize(Type *tp)
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");
}
diff --git a/cc1/types.c b/cc1/types.c
index c750604..0420c16 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -263,6 +263,7 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
case UNION: c = L_UNION; break;
}
+ memset(&type, 0, sizeof(type));
type.type = tp;
type.op = op;
type.prop = k_r ? TK_R : 0;
_AT_@ -306,6 +307,8 @@ mktype(Type *tp, int op, TINT nelem, Type *pars[])
}
}
+ if (type.prop & TDEFINED)
+ typesize(&type);
bp = xmalloc(sizeof(*bp));
*bp = type;
bp->id = newid();
Received on Thu Dec 01 2016 - 09:44:14 CET
This archive was generated by hypermail 2.3.0
: Thu Dec 01 2016 - 09:48:20 CET