Home | History | Annotate | Line # | Download | only in lint1
init.c revision 1.82
      1  1.82    rillig /*	$NetBSD: init.c,v 1.82 2021/02/21 13:13:14 rillig Exp $	*/
      2   1.2       cgd 
      3   1.1       cgd /*
      4   1.1       cgd  * Copyright (c) 1994, 1995 Jochen Pohl
      5   1.1       cgd  * All Rights Reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1       cgd  * modification, are permitted provided that the following conditions
      9   1.1       cgd  * are met:
     10   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     16   1.1       cgd  *    must display the following acknowledgement:
     17   1.1       cgd  *      This product includes software developed by Jochen Pohl for
     18   1.1       cgd  *	The NetBSD Project.
     19   1.1       cgd  * 4. The name of the author may not be used to endorse or promote products
     20   1.1       cgd  *    derived from this software without specific prior written permission.
     21   1.1       cgd  *
     22   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23   1.1       cgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24   1.1       cgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25   1.1       cgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26   1.1       cgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27   1.1       cgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28   1.1       cgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29   1.1       cgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30   1.1       cgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31   1.1       cgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32   1.1       cgd  */
     33   1.1       cgd 
     34  1.18       jmc #if HAVE_NBTOOL_CONFIG_H
     35  1.18       jmc #include "nbtool_config.h"
     36  1.18       jmc #endif
     37  1.18       jmc 
     38   1.5  christos #include <sys/cdefs.h>
     39  1.10        tv #if defined(__RCSID) && !defined(lint)
     40  1.82    rillig __RCSID("$NetBSD: init.c,v 1.82 2021/02/21 13:13:14 rillig Exp $");
     41   1.1       cgd #endif
     42   1.1       cgd 
     43   1.1       cgd #include <stdlib.h>
     44  1.17   thorpej #include <string.h>
     45   1.1       cgd 
     46   1.1       cgd #include "lint1.h"
     47   1.1       cgd 
     48  1.53    rillig 
     49  1.53    rillig /*
     50  1.53    rillig  * Type of stack which is used for initialisation of aggregate types.
     51  1.54    rillig  *
     52  1.54    rillig  * XXX: Since C99, a stack is an inappropriate data structure for modelling
     53  1.54    rillig  * an initialization, since the designators don't have to be listed in a
     54  1.54    rillig  * particular order and can designate parts of sub-objects.  The member names
     55  1.54    rillig  * of non-leaf structs may thus appear repeatedly, as demonstrated in
     56  1.54    rillig  * d_init_pop_member.c.
     57  1.54    rillig  *
     58  1.54    rillig  * XXX: During initialization, there may be members of the top-level struct
     59  1.54    rillig  * that are partially initialized.  The simple i_remaining cannot model this
     60  1.54    rillig  * appropriately.
     61  1.54    rillig  *
     62  1.54    rillig  * See C99 6.7.8, which spans 6 pages full of tricky details and carefully
     63  1.54    rillig  * selected examples.
     64  1.53    rillig  */
     65  1.79    rillig typedef	struct initstack_element {
     66  1.77    rillig 
     67  1.77    rillig 	/* XXX: Why is i_type often null? */
     68  1.53    rillig 	type_t	*i_type;		/* type of initialisation */
     69  1.53    rillig 	type_t	*i_subt;		/* type of next level */
     70  1.77    rillig 
     71  1.82    rillig 	/*
     72  1.82    rillig 	 * This level of the initializer requires a '}' to be completed.
     73  1.82    rillig 	 *
     74  1.82    rillig 	 * Multidimensional arrays do not need a closing brace to complete
     75  1.82    rillig 	 * an inner array; for example, { 1, 2, 3, 4 } is a valid initializer
     76  1.82    rillig 	 * for int arr[2][2].
     77  1.82    rillig 	 *
     78  1.82    rillig 	 * TODO: Do structs containing structs need a closing brace?
     79  1.82    rillig 	 * TODO: Do arrays of structs need a closing brace after each struct?
     80  1.82    rillig 	 */
     81  1.77    rillig 	bool i_brace: 1;
     82  1.82    rillig 
     83  1.77    rillig 	bool i_array_of_unknown_size: 1;
     84  1.77    rillig 	bool i_seen_named_member: 1;
     85  1.77    rillig 
     86  1.77    rillig 	/*
     87  1.78    rillig 	 * For structs, the next member to be initialized by an initializer
     88  1.78    rillig 	 * without an optional designator.
     89  1.77    rillig 	 */
     90  1.77    rillig 	sym_t *i_current_object;
     91  1.77    rillig 
     92  1.77    rillig 	/*
     93  1.77    rillig 	 * The number of remaining elements.
     94  1.77    rillig 	 *
     95  1.77    rillig 	 * XXX: for scalars?
     96  1.77    rillig 	 * XXX: for structs?
     97  1.77    rillig 	 * XXX: for unions?
     98  1.77    rillig 	 * XXX: for arrays?
     99  1.77    rillig 	 */
    100  1.77    rillig 	int i_remaining;
    101  1.77    rillig 
    102  1.77    rillig 	/*
    103  1.77    rillig 	 * The initialization state of the enclosing data structure
    104  1.77    rillig 	 * (struct, union, array).
    105  1.77    rillig 	 */
    106  1.79    rillig 	struct initstack_element *i_enclosing;
    107  1.79    rillig } initstack_element;
    108  1.53    rillig 
    109  1.55    rillig /*
    110  1.55    rillig  * The names for a nested C99 initialization designator, in a circular list.
    111  1.55    rillig  *
    112  1.55    rillig  * Example:
    113  1.55    rillig  *	struct stat st = {
    114  1.55    rillig  *		.st_size = 123,
    115  1.55    rillig  *		.st_mtim.tv_sec = 45,
    116  1.55    rillig  *		.st_mtim.tv_nsec
    117  1.55    rillig  *	};
    118  1.55    rillig  *
    119  1.55    rillig  *	During initialization, this list first contains ["st_size"], then
    120  1.55    rillig  *	["st_mtim", "tv_sec"], then ["st_mtim", "tv_nsec"].
    121  1.55    rillig  */
    122  1.53    rillig typedef struct namlist {
    123  1.53    rillig 	const char *n_name;
    124  1.53    rillig 	struct namlist *n_prev;
    125  1.53    rillig 	struct namlist *n_next;
    126  1.53    rillig } namlist_t;
    127  1.53    rillig 
    128  1.53    rillig 
    129   1.1       cgd /*
    130   1.8       wiz  * initerr is set as soon as a fatal error occurred in an initialisation.
    131   1.1       cgd  * The effect is that the rest of the initialisation is ignored (parsed
    132   1.1       cgd  * by yacc, expression trees built, but no initialisation takes place).
    133   1.1       cgd  */
    134  1.62    rillig bool	initerr;
    135   1.1       cgd 
    136   1.1       cgd /* Pointer to the symbol which is to be initialized. */
    137   1.1       cgd sym_t	*initsym;
    138   1.1       cgd 
    139   1.1       cgd /* Points to the top element of the initialisation stack. */
    140  1.79    rillig initstack_element *initstk;
    141   1.1       cgd 
    142  1.12  christos /* Points to a c9x named member; */
    143  1.12  christos namlist_t	*namedmem = NULL;
    144  1.12  christos 
    145   1.1       cgd 
    146  1.82    rillig static	bool	init_array_using_string(tnode_t *);
    147  1.12  christos 
    148  1.12  christos #ifndef DEBUG
    149  1.75    rillig #define debug_printf(fmt, ...)	do { } while (false)
    150  1.75    rillig #define debug_indent()		do { } while (false)
    151  1.75    rillig #define debug_enter(a)		do { } while (false)
    152  1.75    rillig #define debug_step(fmt, ...)	do { } while (false)
    153  1.75    rillig #define debug_leave(a)		do { } while (false)
    154  1.12  christos #else
    155  1.68    rillig static int debug_ind = 0;
    156  1.68    rillig 
    157  1.68    rillig static void __printflike(1, 2)
    158  1.68    rillig debug_printf(const char *fmt, ...)
    159  1.68    rillig {
    160  1.68    rillig 	va_list va;
    161  1.68    rillig 
    162  1.68    rillig 	va_start(va, fmt);
    163  1.68    rillig 	vfprintf(stdout, fmt, va);
    164  1.68    rillig 	va_end(va);
    165  1.68    rillig }
    166  1.68    rillig 
    167  1.68    rillig static void
    168  1.68    rillig debug_indent(void)
    169  1.68    rillig {
    170  1.68    rillig 	debug_printf("%*s", 2 * debug_ind, "");
    171  1.68    rillig }
    172  1.68    rillig 
    173  1.68    rillig static void
    174  1.68    rillig debug_enter(const char *func)
    175  1.68    rillig {
    176  1.68    rillig 	printf("%*s+ %s\n", 2 * debug_ind++, "", func);
    177  1.68    rillig }
    178  1.68    rillig 
    179  1.68    rillig static void __printflike(1, 2)
    180  1.68    rillig debug_step(const char *fmt, ...)
    181  1.68    rillig {
    182  1.68    rillig 	va_list va;
    183  1.68    rillig 
    184  1.68    rillig 	printf("%*s", 2 * debug_ind, "");
    185  1.68    rillig 	va_start(va, fmt);
    186  1.68    rillig 	vfprintf(stdout, fmt, va);
    187  1.68    rillig 	va_end(va);
    188  1.68    rillig 	printf("\n");
    189  1.68    rillig }
    190  1.68    rillig 
    191  1.68    rillig static void
    192  1.68    rillig debug_leave(const char *func)
    193  1.68    rillig {
    194  1.68    rillig 	printf("%*s- %s\n", 2 * --debug_ind, "", func);
    195  1.68    rillig }
    196  1.68    rillig 
    197  1.68    rillig #define debug_enter() debug_enter(__func__)
    198  1.68    rillig #define debug_leave() debug_leave(__func__)
    199  1.68    rillig 
    200  1.12  christos #endif
    201  1.12  christos 
    202  1.12  christos void
    203  1.51    rillig push_member(sbuf_t *sb)
    204  1.12  christos {
    205  1.28    rillig 	namlist_t *nam = xcalloc(1, sizeof (namlist_t));
    206  1.12  christos 	nam->n_name = sb->sb_name;
    207  1.70    rillig 
    208  1.71    rillig 	debug_step("%s: '%s' %p", __func__, nam->n_name, nam);
    209  1.70    rillig 
    210  1.12  christos 	if (namedmem == NULL) {
    211  1.51    rillig 		/*
    212  1.51    rillig 		 * XXX: Why is this a circular list?
    213  1.51    rillig 		 * XXX: Why is this a doubly-linked list?
    214  1.51    rillig 		 * A simple stack should suffice.
    215  1.51    rillig 		 */
    216  1.12  christos 		nam->n_prev = nam->n_next = nam;
    217  1.12  christos 		namedmem = nam;
    218  1.12  christos 	} else {
    219  1.12  christos 		namedmem->n_prev->n_next = nam;
    220  1.12  christos 		nam->n_prev = namedmem->n_prev;
    221  1.12  christos 		nam->n_next = namedmem;
    222  1.12  christos 		namedmem->n_prev = nam;
    223  1.12  christos 	}
    224  1.12  christos }
    225  1.12  christos 
    226  1.12  christos static void
    227  1.34    rillig pop_member(void)
    228  1.12  christos {
    229  1.68    rillig 	debug_step("%s: %s %p", __func__, namedmem->n_name, namedmem);
    230  1.12  christos 	if (namedmem->n_next == namedmem) {
    231  1.12  christos 		free(namedmem);
    232  1.12  christos 		namedmem = NULL;
    233  1.12  christos 	} else {
    234  1.12  christos 		namlist_t *nam = namedmem;
    235  1.12  christos 		namedmem = namedmem->n_next;
    236  1.52    rillig 		nam->n_prev->n_next = nam->n_next;
    237  1.52    rillig 		nam->n_next->n_prev = nam->n_prev;
    238  1.12  christos 		free(nam);
    239  1.12  christos 	}
    240  1.12  christos }
    241   1.1       cgd 
    242  1.72    rillig #ifdef DEBUG
    243  1.55    rillig static void
    244  1.68    rillig debug_named_member(void)
    245  1.55    rillig {
    246  1.55    rillig 	namlist_t *name;
    247  1.55    rillig 
    248  1.55    rillig 	if (namedmem == NULL)
    249  1.55    rillig 		return;
    250  1.55    rillig 	name = namedmem;
    251  1.68    rillig 	debug_indent();
    252  1.68    rillig 	debug_printf("named member:");
    253  1.55    rillig 	do {
    254  1.68    rillig 		debug_printf(" %s", name->n_name);
    255  1.55    rillig 		name = name->n_next;
    256  1.55    rillig 	} while (name != namedmem);
    257  1.68    rillig 	debug_printf("\n");
    258  1.55    rillig }
    259  1.72    rillig #else
    260  1.75    rillig #define debug_named_member()	do { } while (false)
    261  1.72    rillig #endif
    262   1.1       cgd 
    263  1.73    rillig #ifdef DEBUG
    264  1.78    rillig static void
    265  1.79    rillig debug_initstack_element(const initstack_element *elem)
    266  1.74    rillig {
    267  1.78    rillig 	if (elem->i_type != NULL)
    268  1.78    rillig 		debug_step("  i_type           = %s", type_name(elem->i_type));
    269  1.78    rillig 	if (elem->i_subt != NULL)
    270  1.78    rillig 		debug_step("  i_subt           = %s", type_name(elem->i_subt));
    271  1.78    rillig 
    272  1.78    rillig 	if (elem->i_brace)
    273  1.78    rillig 		debug_step("  i_brace");
    274  1.78    rillig 	if (elem->i_array_of_unknown_size)
    275  1.78    rillig 		debug_step("  i_array_of_unknown_size");
    276  1.78    rillig 	if (elem->i_seen_named_member)
    277  1.78    rillig 		debug_step("  i_seen_named_member");
    278  1.78    rillig 
    279  1.78    rillig 	const type_t *eff_type = elem->i_type != NULL
    280  1.78    rillig 	    ? elem->i_type : elem->i_subt;
    281  1.78    rillig 	if (eff_type->t_tspec == STRUCT && elem->i_current_object != NULL)
    282  1.78    rillig 		debug_step("  i_current_object = %s",
    283  1.78    rillig 		    elem->i_current_object->s_name);
    284  1.78    rillig 
    285  1.78    rillig 	debug_step("  i_remaining      = %d", elem->i_remaining);
    286  1.74    rillig }
    287  1.74    rillig 
    288  1.73    rillig static void
    289  1.73    rillig debug_initstack(void)
    290  1.73    rillig {
    291  1.73    rillig 	if (initstk == NULL) {
    292  1.73    rillig 		debug_step("initstk is empty");
    293  1.73    rillig 		return;
    294  1.73    rillig 	}
    295  1.73    rillig 
    296  1.73    rillig 	size_t i = 0;
    297  1.79    rillig 	for (const initstack_element *elem = initstk;
    298  1.77    rillig 	     elem != NULL; elem = elem->i_enclosing) {
    299  1.73    rillig 		debug_step("initstk[%zu]:", i);
    300  1.78    rillig 		debug_initstack_element(elem);
    301  1.73    rillig 		i++;
    302  1.73    rillig 	}
    303  1.73    rillig }
    304  1.73    rillig #else
    305  1.80    rillig #define debug_initstack_element(elem) do { } while (false)
    306  1.75    rillig #define debug_initstack()	do { } while (false)
    307  1.73    rillig #endif
    308  1.73    rillig 
    309   1.1       cgd /*
    310  1.77    rillig  * Initialize the initialisation stack by putting an entry for the object
    311   1.1       cgd  * which is to be initialized on it.
    312   1.1       cgd  */
    313   1.1       cgd void
    314  1.35    rillig initstack_init(void)
    315   1.1       cgd {
    316  1.79    rillig 	initstack_element *istk;
    317   1.1       cgd 
    318   1.1       cgd 	if (initerr)
    319   1.1       cgd 		return;
    320   1.1       cgd 
    321   1.1       cgd 	/* free memory used in last initialisation */
    322   1.1       cgd 	while ((istk = initstk) != NULL) {
    323  1.77    rillig 		initstk = istk->i_enclosing;
    324   1.1       cgd 		free(istk);
    325   1.1       cgd 	}
    326   1.1       cgd 
    327  1.70    rillig 	debug_enter();
    328  1.38    rillig 
    329   1.1       cgd 	/*
    330  1.77    rillig 	 * If the type which is to be initialized is an incomplete array,
    331   1.1       cgd 	 * it must be duplicated.
    332   1.1       cgd 	 */
    333  1.65    rillig 	if (initsym->s_type->t_tspec == ARRAY && is_incomplete(initsym->s_type))
    334   1.1       cgd 		initsym->s_type = duptyp(initsym->s_type);
    335   1.1       cgd 
    336  1.79    rillig 	istk = initstk = xcalloc(1, sizeof (initstack_element));
    337   1.1       cgd 	istk->i_subt = initsym->s_type;
    338  1.43    rillig 	istk->i_remaining = 1;
    339  1.70    rillig 
    340  1.73    rillig 	debug_initstack();
    341  1.70    rillig 	debug_leave();
    342   1.1       cgd }
    343   1.1       cgd 
    344   1.1       cgd static void
    345  1.35    rillig initstack_pop_item(void)
    346   1.1       cgd {
    347  1.79    rillig 	initstack_element *istk;
    348   1.1       cgd 	sym_t	*m;
    349   1.1       cgd 
    350  1.68    rillig 	debug_enter();
    351  1.68    rillig 
    352  1.41    rillig 	istk = initstk;
    353  1.80    rillig 	debug_step("popping:");
    354  1.80    rillig 	debug_initstack_element(istk);
    355  1.40    rillig 
    356  1.77    rillig 	initstk = istk->i_enclosing;
    357   1.1       cgd 	free(istk);
    358   1.1       cgd 	istk = initstk;
    359  1.44    rillig 	lint_assert(istk != NULL);
    360  1.26  christos 
    361  1.43    rillig 	istk->i_remaining--;
    362  1.44    rillig 	lint_assert(istk->i_remaining >= 0);
    363   1.1       cgd 
    364  1.80    rillig 	debug_step("new top element with updated remaining:");
    365  1.80    rillig 	debug_initstack_element(istk);
    366  1.40    rillig 
    367  1.80    rillig 	if (namedmem != NULL) {
    368  1.80    rillig 		debug_step("initializing named member '%s'", namedmem->n_name);
    369  1.38    rillig 
    370  1.80    rillig 		/* XXX: undefined behavior if this is reached with an array? */
    371  1.67    rillig 		for (m = istk->i_type->t_str->sou_first_member;
    372  1.67    rillig 		     m != NULL; m = m->s_next) {
    373  1.80    rillig 
    374  1.48    rillig 			if (m->s_bitfield && m->s_name == unnamed)
    375  1.12  christos 				continue;
    376  1.80    rillig 
    377  1.12  christos 			if (strcmp(m->s_name, namedmem->n_name) == 0) {
    378  1.80    rillig 				debug_step("found matching member");
    379  1.12  christos 				istk->i_subt = m->s_type;
    380  1.80    rillig 				/* XXX: why ++? */
    381  1.43    rillig 				istk->i_remaining++;
    382  1.80    rillig 				/* XXX: why is i_seen_named_member not set? */
    383  1.34    rillig 				pop_member();
    384  1.73    rillig 				debug_initstack();
    385  1.68    rillig 				debug_leave();
    386  1.12  christos 				return;
    387  1.12  christos 			}
    388  1.12  christos 		}
    389  1.80    rillig 
    390  1.50    rillig 		/* undefined struct/union member: %s */
    391  1.12  christos 		error(101, namedmem->n_name);
    392  1.80    rillig 
    393  1.34    rillig 		pop_member();
    394  1.77    rillig 		istk->i_seen_named_member = true;
    395  1.73    rillig 		debug_initstack();
    396  1.68    rillig 		debug_leave();
    397  1.12  christos 		return;
    398  1.12  christos 	}
    399  1.80    rillig 
    400   1.1       cgd 	/*
    401   1.1       cgd 	 * If the removed element was a structure member, we must go
    402   1.1       cgd 	 * to the next structure member.
    403   1.1       cgd 	 */
    404  1.43    rillig 	if (istk->i_remaining > 0 && istk->i_type->t_tspec == STRUCT &&
    405  1.77    rillig 	    !istk->i_seen_named_member) {
    406   1.1       cgd 		do {
    407  1.77    rillig 			m = istk->i_current_object =
    408  1.77    rillig 			    istk->i_current_object->s_next;
    409  1.80    rillig 			/* XXX: can this assertion be made to fail? */
    410  1.44    rillig 			lint_assert(m != NULL);
    411  1.68    rillig 			debug_step("pop %s", m->s_name);
    412  1.48    rillig 		} while (m->s_bitfield && m->s_name == unnamed);
    413  1.80    rillig 		/* XXX: duplicate code for skipping unnamed bit-fields */
    414   1.1       cgd 		istk->i_subt = m->s_type;
    415   1.1       cgd 	}
    416  1.73    rillig 	debug_initstack();
    417  1.68    rillig 	debug_leave();
    418   1.1       cgd }
    419   1.1       cgd 
    420  1.36    rillig /*
    421  1.36    rillig  * Take all entries, including the first which requires a closing brace,
    422  1.36    rillig  * from the stack.
    423  1.36    rillig  */
    424  1.36    rillig static void
    425  1.36    rillig initstack_pop_brace(void)
    426  1.36    rillig {
    427  1.62    rillig 	bool brace;
    428  1.36    rillig 
    429  1.68    rillig 	debug_enter();
    430  1.73    rillig 	debug_initstack();
    431  1.36    rillig 	do {
    432  1.36    rillig 		brace = initstk->i_brace;
    433  1.68    rillig 		debug_step("loop brace=%d", brace);
    434  1.36    rillig 		initstack_pop_item();
    435  1.36    rillig 	} while (!brace);
    436  1.73    rillig 	debug_initstack();
    437  1.68    rillig 	debug_leave();
    438  1.36    rillig }
    439  1.36    rillig 
    440  1.36    rillig /*
    441  1.36    rillig  * Take all entries which cannot be used for further initializers from the
    442  1.36    rillig  * stack, but do this only if they do not require a closing brace.
    443  1.36    rillig  */
    444   1.1       cgd static void
    445  1.36    rillig initstack_pop_nobrace(void)
    446   1.1       cgd {
    447   1.7     lukem 
    448  1.68    rillig 	debug_enter();
    449  1.73    rillig 	debug_initstack();
    450  1.43    rillig 	while (!initstk->i_brace && initstk->i_remaining == 0 &&
    451  1.77    rillig 	       !initstk->i_array_of_unknown_size)
    452  1.36    rillig 		initstack_pop_item();
    453  1.73    rillig 	debug_initstack();
    454  1.68    rillig 	debug_leave();
    455   1.1       cgd }
    456   1.1       cgd 
    457   1.1       cgd static void
    458  1.35    rillig initstack_push(void)
    459   1.1       cgd {
    460  1.79    rillig 	initstack_element *istk, *inxt;
    461   1.1       cgd 	int	cnt;
    462   1.1       cgd 	sym_t	*m;
    463   1.1       cgd 
    464  1.68    rillig 	debug_enter();
    465  1.73    rillig 	debug_initstack();
    466  1.68    rillig 
    467   1.1       cgd 	istk = initstk;
    468   1.1       cgd 
    469   1.1       cgd 	/* Extend an incomplete array type by one element */
    470  1.43    rillig 	if (istk->i_remaining == 0) {
    471  1.68    rillig 		debug_step("(extend) %s", type_name(istk->i_type));
    472   1.1       cgd 		/*
    473   1.1       cgd 		 * Inside of other aggregate types must not be an incomplete
    474   1.1       cgd 		 * type.
    475   1.1       cgd 		 */
    476  1.77    rillig 		lint_assert(istk->i_enclosing->i_enclosing == NULL);
    477  1.43    rillig 		istk->i_remaining = 1;
    478  1.44    rillig 		lint_assert(istk->i_type->t_tspec == ARRAY);
    479   1.1       cgd 		istk->i_type->t_dim++;
    480  1.63    rillig 		setcomplete(istk->i_type, true);
    481   1.1       cgd 	}
    482   1.1       cgd 
    483  1.44    rillig 	lint_assert(istk->i_remaining > 0);
    484  1.61    rillig 	lint_assert(istk->i_type == NULL || !is_scalar(istk->i_type->t_tspec));
    485   1.1       cgd 
    486  1.79    rillig 	initstk = xcalloc(1, sizeof (initstack_element));
    487  1.77    rillig 	initstk->i_enclosing = istk;
    488   1.1       cgd 	initstk->i_type = istk->i_subt;
    489  1.44    rillig 	lint_assert(initstk->i_type->t_tspec != FUNC);
    490   1.1       cgd 
    491  1.12  christos again:
    492   1.1       cgd 	istk = initstk;
    493   1.1       cgd 
    494  1.68    rillig 	debug_step("typename %s", type_name(istk->i_type));
    495   1.1       cgd 	switch (istk->i_type->t_tspec) {
    496   1.1       cgd 	case ARRAY:
    497  1.62    rillig 		if (namedmem != NULL) {
    498  1.68    rillig 			debug_step("ARRAY %s brace=%d",
    499  1.68    rillig 			    namedmem->n_name, istk->i_brace);
    500  1.19  christos 			goto pop;
    501  1.77    rillig 		} else if (istk->i_enclosing->i_seen_named_member) {
    502  1.62    rillig 			istk->i_brace = true;
    503  1.68    rillig 			debug_step("ARRAY brace=%d, namedmem=%d",
    504  1.77    rillig 			    istk->i_brace,
    505  1.77    rillig 			    istk->i_enclosing->i_seen_named_member);
    506  1.20  christos 		}
    507  1.20  christos 
    508  1.65    rillig 		if (is_incomplete(istk->i_type) &&
    509  1.77    rillig 		    istk->i_enclosing->i_enclosing != NULL) {
    510   1.1       cgd 			/* initialisation of an incomplete type */
    511   1.1       cgd 			error(175);
    512  1.62    rillig 			initerr = true;
    513  1.73    rillig 			debug_initstack();
    514  1.68    rillig 			debug_leave();
    515   1.1       cgd 			return;
    516   1.1       cgd 		}
    517   1.1       cgd 		istk->i_subt = istk->i_type->t_subt;
    518  1.77    rillig 		istk->i_array_of_unknown_size = is_incomplete(istk->i_type);
    519  1.43    rillig 		istk->i_remaining = istk->i_type->t_dim;
    520  1.68    rillig 		debug_step("elements array %s[%d] %s",
    521  1.57    rillig 		    type_name(istk->i_subt), istk->i_remaining,
    522  1.74    rillig 		    namedmem != NULL ? namedmem->n_name : "*none*");
    523   1.1       cgd 		break;
    524   1.1       cgd 	case UNION:
    525   1.1       cgd 		if (tflag)
    526   1.1       cgd 			/* initialisation of union is illegal in trad. C */
    527   1.1       cgd 			warning(238);
    528   1.1       cgd 		/* FALLTHROUGH */
    529   1.1       cgd 	case STRUCT:
    530  1.65    rillig 		if (is_incomplete(istk->i_type)) {
    531   1.1       cgd 			/* initialisation of an incomplete type */
    532   1.1       cgd 			error(175);
    533  1.62    rillig 			initerr = true;
    534  1.73    rillig 			debug_initstack();
    535  1.68    rillig 			debug_leave();
    536   1.1       cgd 			return;
    537   1.1       cgd 		}
    538   1.1       cgd 		cnt = 0;
    539  1.68    rillig 		debug_step("lookup type=%s, name=%s named=%d",
    540  1.57    rillig 		    type_name(istk->i_type),
    541  1.74    rillig 		    namedmem != NULL ? namedmem->n_name : "*none*",
    542  1.77    rillig 		    istk->i_seen_named_member);
    543  1.67    rillig 		for (m = istk->i_type->t_str->sou_first_member;
    544  1.67    rillig 		     m != NULL; m = m->s_next) {
    545  1.48    rillig 			if (m->s_bitfield && m->s_name == unnamed)
    546   1.1       cgd 				continue;
    547  1.12  christos 			if (namedmem != NULL) {
    548  1.68    rillig 				debug_step("named lhs.member=%s, rhs.member=%s",
    549  1.68    rillig 				    m->s_name, namedmem->n_name);
    550  1.12  christos 				if (strcmp(m->s_name, namedmem->n_name) == 0) {
    551  1.12  christos 					cnt++;
    552  1.12  christos 					break;
    553  1.12  christos 				} else
    554  1.12  christos 					continue;
    555  1.12  christos 			}
    556   1.1       cgd 			if (++cnt == 1) {
    557  1.77    rillig 				istk->i_current_object = m;
    558   1.1       cgd 				istk->i_subt = m->s_type;
    559   1.1       cgd 			}
    560   1.1       cgd 		}
    561  1.12  christos 		if (namedmem != NULL) {
    562  1.12  christos 			if (m == NULL) {
    563  1.68    rillig 				debug_step("pop struct");
    564  1.19  christos 				goto pop;
    565  1.28    rillig 			}
    566  1.77    rillig 			istk->i_current_object = m;
    567  1.26  christos 			istk->i_subt = m->s_type;
    568  1.77    rillig 			istk->i_seen_named_member = true;
    569  1.68    rillig 			debug_step("named name=%s", namedmem->n_name);
    570  1.34    rillig 			pop_member();
    571  1.12  christos 			cnt = istk->i_type->t_tspec == STRUCT ? 2 : 1;
    572  1.12  christos 		}
    573  1.62    rillig 		istk->i_brace = true;
    574  1.68    rillig 		debug_step("unnamed type=%s, brace=%d",
    575  1.74    rillig 		    type_name(
    576  1.74    rillig 			istk->i_type != NULL ? istk->i_type : istk->i_subt),
    577  1.68    rillig 		    istk->i_brace);
    578   1.1       cgd 		if (cnt == 0) {
    579   1.1       cgd 			/* cannot init. struct/union with no named member */
    580   1.1       cgd 			error(179);
    581  1.62    rillig 			initerr = true;
    582  1.73    rillig 			debug_initstack();
    583  1.68    rillig 			debug_leave();
    584   1.1       cgd 			return;
    585   1.1       cgd 		}
    586  1.43    rillig 		istk->i_remaining = istk->i_type->t_tspec == STRUCT ? cnt : 1;
    587   1.1       cgd 		break;
    588   1.1       cgd 	default:
    589  1.62    rillig 		if (namedmem != NULL) {
    590  1.68    rillig 			debug_step("pop");
    591  1.19  christos 	pop:
    592  1.77    rillig 			inxt = initstk->i_enclosing;
    593  1.12  christos 			free(istk);
    594  1.22        ad 			initstk = inxt;
    595  1.12  christos 			goto again;
    596  1.12  christos 		}
    597  1.43    rillig 		istk->i_remaining = 1;
    598   1.1       cgd 		break;
    599   1.1       cgd 	}
    600  1.68    rillig 
    601  1.73    rillig 	debug_initstack();
    602  1.68    rillig 	debug_leave();
    603   1.1       cgd }
    604   1.1       cgd 
    605   1.1       cgd static void
    606  1.35    rillig initstack_check_too_many(void)
    607   1.1       cgd {
    608  1.79    rillig 	initstack_element *istk;
    609   1.1       cgd 
    610   1.1       cgd 	istk = initstk;
    611   1.1       cgd 
    612   1.1       cgd 	/*
    613   1.1       cgd 	 * If a closing brace is expected we have at least one initializer
    614   1.1       cgd 	 * too much.
    615   1.1       cgd 	 */
    616  1.77    rillig 	if (istk->i_remaining == 0 && !istk->i_array_of_unknown_size &&
    617  1.77    rillig 	    !istk->i_seen_named_member) {
    618   1.1       cgd 		switch (istk->i_type->t_tspec) {
    619   1.1       cgd 		case ARRAY:
    620  1.49    rillig 			/* too many array initializers, expected %d */
    621  1.23  christos 			error(173, istk->i_type->t_dim);
    622   1.1       cgd 			break;
    623   1.1       cgd 		case STRUCT:
    624   1.1       cgd 		case UNION:
    625   1.1       cgd 			/* too many struct/union initializers */
    626   1.1       cgd 			error(172);
    627   1.1       cgd 			break;
    628   1.1       cgd 		default:
    629   1.1       cgd 			/* too many initializers */
    630   1.1       cgd 			error(174);
    631   1.1       cgd 			break;
    632   1.1       cgd 		}
    633  1.62    rillig 		initerr = true;
    634   1.1       cgd 	}
    635   1.1       cgd }
    636   1.1       cgd 
    637   1.1       cgd static void
    638  1.37    rillig initstack_next_brace(void)
    639   1.1       cgd {
    640   1.7     lukem 
    641  1.68    rillig 	debug_enter();
    642  1.73    rillig 	debug_initstack();
    643  1.68    rillig 
    644  1.61    rillig 	if (initstk->i_type != NULL && is_scalar(initstk->i_type->t_tspec)) {
    645  1.49    rillig 		/* invalid initializer type %s */
    646  1.57    rillig 		error(176, type_name(initstk->i_type));
    647  1.62    rillig 		initerr = true;
    648  1.37    rillig 	}
    649  1.37    rillig 	if (!initerr)
    650  1.37    rillig 		initstack_check_too_many();
    651  1.37    rillig 	if (!initerr)
    652  1.37    rillig 		initstack_push();
    653  1.37    rillig 	if (!initerr) {
    654  1.62    rillig 		initstk->i_brace = true;
    655  1.68    rillig 		debug_step("%p %s", namedmem, type_name(
    656  1.74    rillig 		    initstk->i_type != NULL ? initstk->i_type
    657  1.74    rillig 			: initstk->i_subt));
    658  1.37    rillig 	}
    659  1.68    rillig 
    660  1.73    rillig 	debug_initstack();
    661  1.68    rillig 	debug_leave();
    662  1.37    rillig }
    663  1.37    rillig 
    664  1.37    rillig static void
    665  1.37    rillig initstack_next_nobrace(void)
    666  1.37    rillig {
    667  1.68    rillig 	debug_enter();
    668  1.73    rillig 	debug_initstack();
    669  1.37    rillig 
    670  1.61    rillig 	if (initstk->i_type == NULL && !is_scalar(initstk->i_subt->t_tspec)) {
    671  1.37    rillig 		/* {}-enclosed initializer required */
    672  1.37    rillig 		error(181);
    673  1.37    rillig 	}
    674  1.37    rillig 
    675  1.71    rillig 	/*
    676  1.71    rillig 	 * Make sure an entry with a scalar type is at the top of the stack.
    677  1.71    rillig 	 *
    678  1.71    rillig 	 * FIXME: Since C99 an initializer for an object with automatic
    679  1.71    rillig 	 *  storage need not be a constant expression anymore.  It is
    680  1.71    rillig 	 *  perfectly fine to initialize a struct with a struct expression,
    681  1.71    rillig 	 *  see d_struct_init_nested.c for a demonstration.
    682  1.71    rillig 	 */
    683  1.37    rillig 	if (!initerr)
    684  1.37    rillig 		initstack_check_too_many();
    685  1.42    rillig 	while (!initerr) {
    686  1.42    rillig 		if ((initstk->i_type != NULL &&
    687  1.61    rillig 		     is_scalar(initstk->i_type->t_tspec)))
    688  1.42    rillig 			break;
    689  1.42    rillig 		initstack_push();
    690   1.1       cgd 	}
    691  1.68    rillig 
    692  1.73    rillig 	debug_initstack();
    693  1.68    rillig 	debug_leave();
    694   1.1       cgd }
    695   1.1       cgd 
    696   1.1       cgd void
    697  1.34    rillig init_lbrace(void)
    698   1.1       cgd {
    699   1.1       cgd 	if (initerr)
    700   1.1       cgd 		return;
    701   1.1       cgd 
    702  1.68    rillig 	debug_enter();
    703  1.73    rillig 	debug_initstack();
    704  1.68    rillig 
    705   1.1       cgd 	if ((initsym->s_scl == AUTO || initsym->s_scl == REG) &&
    706  1.77    rillig 	    initstk->i_enclosing == NULL) {
    707  1.61    rillig 		if (tflag && !is_scalar(initstk->i_subt->t_tspec))
    708  1.50    rillig 			/* no automatic aggregate initialization in trad. C */
    709   1.1       cgd 			warning(188);
    710   1.1       cgd 	}
    711   1.1       cgd 
    712   1.1       cgd 	/*
    713   1.1       cgd 	 * Remove all entries which cannot be used for further initializers
    714   1.1       cgd 	 * and do not expect a closing brace.
    715   1.1       cgd 	 */
    716  1.36    rillig 	initstack_pop_nobrace();
    717   1.1       cgd 
    718  1.37    rillig 	initstack_next_brace();
    719  1.68    rillig 
    720  1.73    rillig 	debug_initstack();
    721  1.68    rillig 	debug_leave();
    722   1.1       cgd }
    723   1.1       cgd 
    724   1.1       cgd void
    725  1.34    rillig init_rbrace(void)
    726   1.1       cgd {
    727   1.1       cgd 	if (initerr)
    728   1.1       cgd 		return;
    729   1.1       cgd 
    730  1.68    rillig 	debug_enter();
    731  1.73    rillig 	debug_initstack();
    732  1.68    rillig 
    733  1.36    rillig 	initstack_pop_brace();
    734  1.68    rillig 
    735  1.73    rillig 	debug_initstack();
    736  1.68    rillig 	debug_leave();
    737   1.1       cgd }
    738   1.1       cgd 
    739   1.1       cgd void
    740  1.69    rillig init_using_expr(tnode_t *tn)
    741   1.1       cgd {
    742   1.1       cgd 	tspec_t	lt, rt;
    743   1.1       cgd 	tnode_t	*ln;
    744   1.1       cgd 	struct	mbl *tmem;
    745  1.81    rillig 	scl_t	sclass;
    746   1.1       cgd 
    747  1.68    rillig 	debug_enter();
    748  1.68    rillig 	debug_named_member();
    749  1.76    rillig 	debug_node(tn, debug_ind);
    750  1.73    rillig 	debug_initstack();
    751  1.55    rillig 
    752  1.68    rillig 	if (initerr || tn == NULL) {
    753  1.68    rillig 		debug_leave();
    754  1.25  christos 		return;
    755  1.68    rillig 	}
    756   1.1       cgd 
    757  1.81    rillig 	sclass = initsym->s_scl;
    758   1.1       cgd 
    759   1.1       cgd 	/*
    760  1.13  christos 	 * Do not test for automatic aggregate initialisation. If the
    761   1.9       wiz 	 * initializer starts with a brace we have the warning already.
    762   1.1       cgd 	 * If not, an error will be printed that the initializer must
    763   1.1       cgd 	 * be enclosed by braces.
    764   1.1       cgd 	 */
    765   1.1       cgd 
    766   1.1       cgd 	/*
    767   1.1       cgd 	 * Local initialisation of non-array-types with only one expression
    768   1.1       cgd 	 * without braces is done by ASSIGN
    769   1.1       cgd 	 */
    770  1.81    rillig 	if ((sclass == AUTO || sclass == REG) &&
    771  1.77    rillig 	    initsym->s_type->t_tspec != ARRAY && initstk->i_enclosing == NULL) {
    772  1.82    rillig 		debug_step("handing over to ASSIGN");
    773  1.60    rillig 		ln = new_name_node(initsym, 0);
    774   1.1       cgd 		ln->tn_type = tduptyp(ln->tn_type);
    775  1.62    rillig 		ln->tn_type->t_const = false;
    776   1.1       cgd 		tn = build(ASSIGN, ln, tn);
    777  1.66    rillig 		expr(tn, false, false, false, false);
    778  1.82    rillig 		/* XXX: why not clean up the initstack here already? */
    779  1.68    rillig 		debug_leave();
    780  1.25  christos 		return;
    781   1.1       cgd 	}
    782   1.1       cgd 
    783  1.36    rillig 	initstack_pop_nobrace();
    784   1.1       cgd 
    785  1.82    rillig 	if (init_array_using_string(tn)) {
    786  1.82    rillig 		debug_step("after initializing the string:");
    787  1.82    rillig 		/* XXX: why not clean up the initstack here already? */
    788  1.73    rillig 		debug_initstack();
    789  1.68    rillig 		debug_leave();
    790  1.25  christos 		return;
    791  1.68    rillig 	}
    792   1.1       cgd 
    793  1.37    rillig 	initstack_next_nobrace();
    794  1.68    rillig 	if (initerr || tn == NULL) {
    795  1.73    rillig 		debug_initstack();
    796  1.68    rillig 		debug_leave();
    797  1.25  christos 		return;
    798  1.68    rillig 	}
    799   1.1       cgd 
    800  1.43    rillig 	initstk->i_remaining--;
    801  1.68    rillig 	debug_step("remaining=%d tn=%p", initstk->i_remaining, tn);
    802   1.1       cgd 	/* Create a temporary node for the left side. */
    803   1.1       cgd 	ln = tgetblk(sizeof (tnode_t));
    804   1.1       cgd 	ln->tn_op = NAME;
    805   1.1       cgd 	ln->tn_type = tduptyp(initstk->i_type);
    806  1.62    rillig 	ln->tn_type->t_const = false;
    807  1.62    rillig 	ln->tn_lvalue = true;
    808   1.1       cgd 	ln->tn_sym = initsym;		/* better than nothing */
    809   1.1       cgd 
    810   1.1       cgd 	tn = cconv(tn);
    811   1.1       cgd 
    812   1.1       cgd 	lt = ln->tn_type->t_tspec;
    813   1.1       cgd 	rt = tn->tn_type->t_tspec;
    814   1.1       cgd 
    815  1.61    rillig 	lint_assert(is_scalar(lt));
    816   1.1       cgd 
    817  1.68    rillig 	if (!typeok(INIT, 0, ln, tn)) {
    818  1.73    rillig 		debug_initstack();
    819  1.68    rillig 		debug_leave();
    820  1.25  christos 		return;
    821  1.68    rillig 	}
    822   1.1       cgd 
    823   1.1       cgd 	/*
    824  1.38    rillig 	 * Store the tree memory. This is necessary because otherwise
    825   1.1       cgd 	 * expr() would free it.
    826   1.1       cgd 	 */
    827   1.1       cgd 	tmem = tsave();
    828  1.66    rillig 	expr(tn, true, false, true, false);
    829   1.1       cgd 	trestor(tmem);
    830   1.7     lukem 
    831  1.61    rillig 	if (is_integer(lt) && ln->tn_type->t_bitfield && !is_integer(rt)) {
    832   1.1       cgd 		/*
    833   1.1       cgd 		 * Bit-fields can be initialized in trad. C only by integer
    834   1.1       cgd 		 * constants.
    835   1.1       cgd 		 */
    836   1.1       cgd 		if (tflag)
    837   1.1       cgd 			/* bit-field initialisation is illegal in trad. C */
    838   1.1       cgd 			warning(186);
    839   1.1       cgd 	}
    840   1.1       cgd 
    841  1.59    rillig 	if (lt != rt || (initstk->i_type->t_bitfield && tn->tn_op == CON))
    842   1.1       cgd 		tn = convert(INIT, 0, initstk->i_type, tn);
    843   1.1       cgd 
    844   1.1       cgd 	if (tn != NULL && tn->tn_op != CON) {
    845  1.81    rillig 		sym_t *sym;
    846  1.81    rillig 		ptrdiff_t offs;
    847  1.64    rillig 		if (!constant_addr(tn, &sym, &offs)) {
    848  1.81    rillig 			if (sclass == AUTO || sclass == REG) {
    849   1.1       cgd 				/* non-constant initializer */
    850  1.58    rillig 				c99ism(177);
    851   1.1       cgd 			} else {
    852   1.1       cgd 				/* non-constant initializer */
    853   1.1       cgd 				error(177);
    854   1.1       cgd 			}
    855   1.1       cgd 		}
    856   1.1       cgd 	}
    857  1.68    rillig 
    858  1.73    rillig 	debug_initstack();
    859  1.68    rillig 	debug_leave();
    860   1.1       cgd }
    861   1.1       cgd 
    862   1.1       cgd 
    863  1.82    rillig /* Initialize a character array or wchar_t array with a string literal. */
    864  1.62    rillig static bool
    865  1.82    rillig init_array_using_string(tnode_t *tn)
    866   1.1       cgd {
    867   1.1       cgd 	tspec_t	t;
    868  1.79    rillig 	initstack_element *istk;
    869   1.1       cgd 	int	len;
    870   1.1       cgd 	strg_t	*strg;
    871   1.1       cgd 
    872   1.1       cgd 	if (tn->tn_op != STRING)
    873  1.63    rillig 		return false;
    874   1.1       cgd 
    875  1.68    rillig 	debug_enter();
    876  1.73    rillig 	debug_initstack();
    877  1.68    rillig 
    878   1.1       cgd 	istk = initstk;
    879  1.47    rillig 	strg = tn->tn_string;
    880   1.1       cgd 
    881   1.1       cgd 	/*
    882   1.1       cgd 	 * Check if we have an array type which can be initialized by
    883   1.1       cgd 	 * the string.
    884   1.1       cgd 	 */
    885  1.12  christos 	if (istk->i_subt != NULL && istk->i_subt->t_tspec == ARRAY) {
    886  1.68    rillig 		debug_step("subt array");
    887   1.1       cgd 		t = istk->i_subt->t_subt->t_tspec;
    888   1.1       cgd 		if (!((strg->st_tspec == CHAR &&
    889   1.1       cgd 		       (t == CHAR || t == UCHAR || t == SCHAR)) ||
    890   1.1       cgd 		      (strg->st_tspec == WCHAR && t == WCHAR))) {
    891  1.68    rillig 			debug_leave();
    892  1.63    rillig 			return false;
    893   1.1       cgd 		}
    894  1.82    rillig 		/* XXX: duplicate code, see below */
    895   1.1       cgd 		/* Put the array at top of stack */
    896  1.35    rillig 		initstack_push();
    897   1.1       cgd 		istk = initstk;
    898   1.1       cgd 	} else if (istk->i_type != NULL && istk->i_type->t_tspec == ARRAY) {
    899  1.68    rillig 		debug_step("type array");
    900   1.1       cgd 		t = istk->i_type->t_subt->t_tspec;
    901   1.1       cgd 		if (!((strg->st_tspec == CHAR &&
    902   1.1       cgd 		       (t == CHAR || t == UCHAR || t == SCHAR)) ||
    903   1.1       cgd 		      (strg->st_tspec == WCHAR && t == WCHAR))) {
    904  1.68    rillig 			debug_leave();
    905  1.63    rillig 			return false;
    906   1.1       cgd 		}
    907  1.82    rillig 		/* XXX: duplicate code, see above */
    908   1.1       cgd 		/*
    909   1.1       cgd 		 * If the array is already partly initialized, we are
    910   1.1       cgd 		 * wrong here.
    911   1.1       cgd 		 */
    912  1.43    rillig 		if (istk->i_remaining != istk->i_type->t_dim)
    913  1.68    rillig 			debug_leave();
    914  1.63    rillig 			return false;
    915   1.1       cgd 	} else {
    916  1.68    rillig 		debug_leave();
    917  1.63    rillig 		return false;
    918   1.1       cgd 	}
    919   1.1       cgd 
    920   1.1       cgd 	/* Get length without trailing NUL character. */
    921   1.1       cgd 	len = strg->st_len;
    922   1.1       cgd 
    923  1.77    rillig 	if (istk->i_array_of_unknown_size) {
    924  1.77    rillig 		istk->i_array_of_unknown_size = false;
    925   1.1       cgd 		istk->i_type->t_dim = len + 1;
    926  1.63    rillig 		setcomplete(istk->i_type, true);
    927   1.1       cgd 	} else {
    928   1.1       cgd 		if (istk->i_type->t_dim < len) {
    929   1.1       cgd 			/* non-null byte ignored in string initializer */
    930   1.1       cgd 			warning(187);
    931   1.1       cgd 		}
    932   1.1       cgd 	}
    933   1.1       cgd 
    934   1.1       cgd 	/* In every case the array is initialized completely. */
    935  1.43    rillig 	istk->i_remaining = 0;
    936   1.1       cgd 
    937  1.73    rillig 	debug_initstack();
    938  1.68    rillig 	debug_leave();
    939  1.63    rillig 	return true;
    940   1.1       cgd }
    941