This handles &MEM_REF["foo", 17] similar to how we handle &"foo"[17].
The former also works when no arra-ref is reconstructed from "foo" + 17.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-08-26  Richard Guenther  <rguent...@suse.de>

        * expr.c (string_constant): Handle &MEM_REF.

Index: gcc/expr.c
===================================================================
*** gcc/expr.c  (revision 178096)
--- gcc/expr.c  (working copy)
*************** string_constant (tree arg, tree *ptr_off
*** 10168,10173 ****
--- 10168,10184 ----
                                    fold_convert (sizetype, lower_bound));
            }
        }
+       else if (TREE_CODE (TREE_OPERAND (arg, 0)) == MEM_REF)
+       {
+         array = TREE_OPERAND (TREE_OPERAND (arg, 0), 0);
+         offset = TREE_OPERAND (TREE_OPERAND (arg, 0), 1);
+         if (TREE_CODE (array) != ADDR_EXPR)
+           return 0;
+         array = TREE_OPERAND (array, 0);
+         if (TREE_CODE (array) != STRING_CST
+             && TREE_CODE (array) != VAR_DECL)
+           return 0;
+       }
        else
        return 0;
      }

Reply via email to