diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 02039cfe606..446c52874c9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2005-11-19 Richard Guenther + + * fold-const.c (fold_indirect_ref_1): Make sure we fold + ARRAY_REFs of constant strings. + 2005-11-19 Jakub Jelinek * gcc.c (version_compare_spec_function): Use '%s' rather than %qs in diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b8576fc31b8..c4dd4f955a7 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11523,9 +11523,15 @@ fold_indirect_ref_1 (tree type, tree op0) { tree op = TREE_OPERAND (sub, 0); tree optype = TREE_TYPE (op); - /* *&p => p */ + /* *&p => p; make sure to handle *&"str"[cst] here. */ if (type == optype) - return op; + { + tree fop = fold_read_from_constant_string (op); + if (fop) + return fop; + else + return op; + } /* *(foo *)&fooarray => fooarray[0] */ else if (TREE_CODE (optype) == ARRAY_TYPE && type == TREE_TYPE (optype))