aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 02039cf..446c528 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-19 Richard Guenther <rguenther@suse.de>
+
+ * fold-const.c (fold_indirect_ref_1): Make sure we fold
+ ARRAY_REFs of constant strings.
+
2005-11-19 Jakub Jelinek <jakub@redhat.com>
* 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 b8576fc..c4dd4f9 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))