From: Joseph Myers Date: Thu, 28 Jul 2005 22:56:03 +0000 (+0100) Subject: re PR c/21873 (infinite warning loop on bad array initializer) X-Git-Tag: releases/gcc-3.4.5~298 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18716d89d4a240fa9dfa93d848703ad117be70d7;p=thirdparty%2Fgcc.git re PR c/21873 (infinite warning loop on bad array initializer) PR c/21873 * c-typeck.c (push_init_level): Don't pop levels without braces if implicit == 1. testsuite: * gcc.dg/init-excess-1.c: New test. From-SVN: r102525 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 37dae8975fb9..c0b6b05577fd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-07-28 Joseph S. Myers + + PR c/21873 + * c-typeck.c (push_init_level): Don't pop levels without braces if + implicit == 1. + 2005-07-28 Gerald Pfeifer * doc/install.texi (Configuration): Update Valgrind homepage. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c9479f08d127..3da121e10f9e 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4634,19 +4634,27 @@ push_init_level (int implicit) tree value = NULL_TREE; /* If we've exhausted any levels that didn't have braces, - pop them now. */ - while (constructor_stack->implicit) + pop them now. If implicit == 1, this will have been done in + process_init_element; do not repeat it here because in the case + of excess initializers for an empty aggregate this leads to an + infinite cycle of popping a level and immediately recreating + it. */ + if (implicit != 1) { - if ((TREE_CODE (constructor_type) == RECORD_TYPE - || TREE_CODE (constructor_type) == UNION_TYPE) - && constructor_fields == 0) - process_init_element (pop_init_level (1)); - else if (TREE_CODE (constructor_type) == ARRAY_TYPE - && constructor_max_index - && tree_int_cst_lt (constructor_max_index, constructor_index)) - process_init_element (pop_init_level (1)); - else - break; + while (constructor_stack->implicit) + { + if ((TREE_CODE (constructor_type) == RECORD_TYPE + || TREE_CODE (constructor_type) == UNION_TYPE) + && constructor_fields == 0) + process_init_element (pop_init_level (1)); + else if (TREE_CODE (constructor_type) == ARRAY_TYPE + && constructor_max_index + && tree_int_cst_lt (constructor_max_index, + constructor_index)) + process_init_element (pop_init_level (1)); + else + break; + } } /* Unless this is an explicit brace, we need to preserve previous diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e9f90da27348..b1df1c2a6410 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-07-28 Joseph S. Myers + + PR c/21873 + * gcc.dg/init-excess-1.c: New test. + 2005-07-28 Richard Sandiford PR c/20187