From 493179dae3e45a9b25767c46c61f04ca3f9a3a17 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 2 Feb 2005 18:03:20 +0000 Subject: [PATCH] re PR c/19435 (spurious warnings with nested array constructors) PR c/19435 * c-typeck.c (really_start_incremental_init): Reset constructor_max_index for arrays of incomplete type. testsuite: * gcc.dg/c99-init-4.c: New test. From-SVN: r94595 --- gcc/ChangeLog | 6 ++++++ gcc/c-typeck.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/c99-init-4.c | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/c99-init-4.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d1096267bbc..9a7054c4ae3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-02-02 Joseph S. Myers + + PR c/19435 + * c-typeck.c (really_start_incremental_init): Reset + constructor_max_index for arrays of incomplete type. + 2005-02-02 Jeff Law * gcse.c (struct reg_set): Store the block index where the register diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 54f9714f514..f04ba73ad75 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4674,7 +4674,10 @@ really_start_incremental_init (tree type) TYPE_MIN_VALUE (TYPE_DOMAIN (constructor_type))); } else - constructor_index = bitsize_zero_node; + { + constructor_index = bitsize_zero_node; + constructor_max_index = NULL_TREE; + } constructor_unfilled_index = constructor_index; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 636dd4fcc3c..ea9c8904b0c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-02-02 Joseph S. Myers + + PR c/19435 + * gcc.dg/c99-init-4.c: New test. + 2005-02-01 Janis Johnson * g++.old-deja/g++.other/init5.C: Remove xfail for powerpc-linux. diff --git a/gcc/testsuite/gcc.dg/c99-init-4.c b/gcc/testsuite/gcc.dg/c99-init-4.c new file mode 100644 index 00000000000..70735578587 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-init-4.c @@ -0,0 +1,8 @@ +/* Test for nested initialization of a compound literal: must not be + checked against outer array bounds. Bug 19435. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +struct s { char *p; }; +struct s a[1] = { { .p = ((char []){ 1, 2 }) } }; -- 2.30.2