scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit ea7eeb566e8f2493e3495d974ba587ffabbe027d
parent 5307c068b49ad94eeaf77b7fa1255ff49fa0a529
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 19 Jan 2016 14:55:15 +0100

Use eqtype() before of decay()

When we have matrices of multiple dimensions the type returned
by initlist() is an array, which must match the type of the
row of the outer array. If we call decay() then the type of the
array is lost.

Diffstat:
cc1/init.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cc1/init.c b/cc1/init.c @@ -98,9 +98,11 @@ initialize(Type *tp) np = (accept('{')) ? initlist(tp) : assign(); sym = np->sym; - if (sym && (sym->flags & ISSTRING) != 0 && tp->op == ARY) { + if (sym && sym->flags&ISSTRING && tp->op == ARY) { btp = tp->type; - if (btp != chartype && btp != uchartype && btp != schartype) { + if (btp != chartype && + btp != uchartype && + btp != schartype) { errorp("array of inappropriate type initialized from string constant"); goto return_zero; } @@ -117,6 +119,8 @@ initialize(Type *tp) return np; } + if (eqtype(tp, np->type)) + return np; if ((aux = convert(decay(np), tp, 0)) != NULL) return aux;