From: Jakub Jelinek Date: Wed, 19 Jan 2005 09:44:48 +0000 (+0100) Subject: re PR c/17297 (ICE with FP vector constructor containing qnan calculation) X-Git-Tag: releases/gcc-3.4.4~291 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=589b44244cbdcd5a76774b508c0c10320eefcc57;p=thirdparty%2Fgcc.git re PR c/17297 (ICE with FP vector constructor containing qnan calculation) PR c/17297 * c-typeck.c (digest_init): Only call build_vector if all constructor elements are *_CST nodes. * gcc.c-torture/compile/20050113-1.c: New testcase. PR middle-end/19164 * c-typeck.c (digest_init): Only call build_vector if inside_init is a CONSTRUCTOR. * gcc.dg/20050113-1.c: New testcase. From-SVN: r93894 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6eaafd01c7be..85510bf8657a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2005-01-19 Jakub Jelinek + + PR c/17297 + * c-typeck.c (digest_init): Only call build_vector if all constructor + elements are *_CST nodes. + + PR middle-end/19164 + * c-typeck.c (digest_init): Only call build_vector if inside_init + is a CONSTRUCTOR. + 2005-01-18 Eric Botcazou PR debug/16261 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 563ab7d49e08..c9479f08d127 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4097,18 +4097,32 @@ digest_init (tree type, tree init, int require_constant) /* Build a VECTOR_CST from a *constant* vector constructor. If the vector constructor is not constant (e.g. {1,2,3,foo()}) then punt below and handle as a constructor. */ - if (code == VECTOR_TYPE - && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT) - && TREE_CONSTANT (inside_init)) - { - if (TREE_CODE (inside_init) == VECTOR_CST - && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)), - TYPE_MAIN_VARIANT (type), - COMPARE_STRICT)) - return inside_init; - else - return build_vector (type, CONSTRUCTOR_ELTS (inside_init)); - } + if (code == VECTOR_TYPE + && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT) + && TREE_CONSTANT (inside_init)) + { + if (TREE_CODE (inside_init) == VECTOR_CST + && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)), + TYPE_MAIN_VARIANT (type), + COMPARE_STRICT)) + return inside_init; + + if (TREE_CODE (inside_init) == CONSTRUCTOR) + { + tree link; + + /* Iterate through elements and check if all constructor + elements are *_CSTs. */ + for (link = CONSTRUCTOR_ELTS (inside_init); + link; + link = TREE_CHAIN (link)) + if (TREE_CODE_CLASS (TREE_CODE (TREE_VALUE (link))) != 'c') + break; + + if (link == NULL) + return build_vector (type, CONSTRUCTOR_ELTS (inside_init)); + } + } /* Any type can be initialized from an expression of the same type, optionally with braces. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9df14f7c95c0..5261abad4945 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2005-01-19 Jakub Jelinek + + PR c/17297 + * gcc.c-torture/compile/20050113-1.c: New testcase. + + PR middle-end/19164 + * gcc.dg/20050113-1.c: New testcase. + 2005-01-18 Eric Botcazou * g++.dg/debug/typedef3.C: New test.