ref: ea7eeb566e8f2493e3495d974ba587ffabbe027d
parent: 5307c068b49ad94eeaf77b7fa1255ff49fa0a529
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 19 09:55:15 EST 2016
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.
--- a/cc1/init.c
+++ b/cc1/init.c
@@ -98,9 +98,11 @@
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 @@
return np;
}
+ if (eqtype(tp, np->type))
+ return np;
if ((aux = convert(decay(np), tp, 0)) != NULL)
return aux;