This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR tree-optimization/45605
Hi,
this patch fixes both problem (and makes string_constant work on CONST_DECLs too)
Bootstrapped/regetested x86_64-linux, OK (with the testcases added into compile testsuite)
Honza
* expr.c (string_constant): Accept CONST_DECL too; check that
DECL_INITIAL is set.
* varpool.c (const_value_known_p): DEBUG_EXPR_DECL
don't have DECL_INITIAL.
Index: expr.c
===================================================================
*** expr.c (revision 164523)
--- expr.c (working copy)
*************** string_constant (tree arg, tree *ptr_off
*** 9854,9865 ****
*ptr_offset = fold_convert (sizetype, offset);
return array;
}
! else if (TREE_CODE (array) == VAR_DECL)
{
int length;
/* Variables initialized to string literals can be handled too. */
if (!const_value_known_p (array)
|| TREE_CODE (DECL_INITIAL (array)) != STRING_CST)
return 0;
--- 9854,9867 ----
*ptr_offset = fold_convert (sizetype, offset);
return array;
}
! 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;
Index: varpool.c
===================================================================
*** varpool.c (revision 164523)
--- varpool.c (working copy)
*************** const_value_known_p (tree decl)
*** 368,374 ****
struct varpool_node *vnode;
if (TREE_CODE (decl) == PARM_DECL
! || TREE_CODE (decl) == RESULT_DECL)
return false;
if (TREE_CODE (decl) == CONST_DECL
--- 368,375 ----
struct varpool_node *vnode;
if (TREE_CODE (decl) == PARM_DECL
! || TREE_CODE (decl) == RESULT_DECL
! || TREE_CODE (decl) == DEBUG_EXPR_DECL)
return false;
if (TREE_CODE (decl) == CONST_DECL