re PR middle-end/45738 (ICE: tree check: expected var_decl, have debug_expr_decl in const_value_known_p, at varpool.c:375)

PR tree-optimization/45738
	PR tree-optimization/45741
	* expr.c (string_constant): Allow CONST_DECL too;
	check that DECL_INITIAL is set.
	* varpool.c (const_value_known_p): Only look into VAR_DECL
	and CONST_DECL.

	* gcc.c-torture/compile/pr45741.c: New.
	* gfortran.fortran-torture/compile/pr45738.f90: New.

From-SVN: r164602
This commit is contained in:
Jan Hubicka 2010-09-24 18:24:45 +02:00 committed by Jan Hubicka
parent 5642f5d5d5
commit 1d0804d4b6
6 changed files with 39 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2010-09-24 Jan Hubicka <jh@suse.cz>
PR tree-optimization/45738
PR tree-optimization/45741
* expr.c (string_constant): Allow CONST_DECL too;
check that DECL_INITIAL is set.
* varpool.c (const_value_known_p): Only look into VAR_DECL
and CONST_DECL.
2010-09-24 Joseph Myers <joseph@codesourcery.com>
* common.opt (undef): New.

View File

@ -9854,12 +9854,14 @@ string_constant (tree arg, tree *ptr_offset)
*ptr_offset = fold_convert (sizetype, offset);
return array;
}
else if (TREE_CODE (array) == VAR_DECL)
else if (TREE_CODE (array) == VAR_DECL
|| TREE_CODE (array) == CONST_DECL)
{
int length;
/* Variables initialized to string literals can be handled too. */
if (!const_value_known_p (array)
|| !DECL_INITIAL (array)
|| TREE_CODE (DECL_INITIAL (array)) != STRING_CST)
return 0;

View File

@ -1,3 +1,10 @@
2010-09-24 Jan Hubicka <jh@suse.cz>
PR tree-optimization/45738
PR tree-optimization/45741
* gcc.c-torture/compile/pr45741.c: New.
* gfortran.fortran-torture/compile/pr45738.f90: New.
2010-09-24 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/cpp/undef-opt-1.c: New test.

View File

@ -0,0 +1,7 @@
static const int data[2048];
void foo (void *ptr)
{
__builtin_memcmp (data, ptr, 1);
}

View File

@ -0,0 +1,11 @@
PROGRAM TestInfinite
integer(8) :: bit_pattern_NegInf_i8 = -4503599627370496_8
integer(8) :: i
real(8) :: r
r = transfer(bit_pattern_NegInf_i8_p,r)
i = transfer(r,i)
END PROGRAM TestInfinite

View File

@ -367,8 +367,8 @@ const_value_known_p (tree decl)
{
struct varpool_node *vnode;
if (TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL)
if (TREE_CODE (decl) != VAR_DECL
&&TREE_CODE (decl) != CONST_DECL)
return false;
if (TREE_CODE (decl) == CONST_DECL