From: Richard Guenther Date: Sat, 19 Nov 2005 21:40:28 +0000 (+0000) Subject: fold-const.c (fold_indirect_ref_1): Make sure we fold ARRAY_REFs of constant strings. X-Git-Tag: releases/gcc-4.2.0~5858 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41b9109a5565194e18132b8949b1952feab6557a;p=thirdparty%2Fgcc.git fold-const.c (fold_indirect_ref_1): Make sure we fold ARRAY_REFs of constant strings. 2005-11-19 Richard Guenther * fold-const.c (fold_indirect_ref_1): Make sure we fold ARRAY_REFs of constant strings. From-SVN: r107229 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 02039cfe6060..446c52874c90 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 b8576fc31b80..c4dd4f955a7e 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))