tree-ssa-structalias.c (get_constraint_for_component_ref): Do not punt for STRING_CST.
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 15 Apr 2008 18:22:51 +0000 (18:22 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 15 Apr 2008 18:22:51 +0000 (18:22 +0000)
* tree-ssa-structalias.c (get_constraint_for_component_ref): Do not
punt for STRING_CST.
(get_constraint_for): Deal with STRING_CST here instead.

From-SVN: r134325

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/string_slice2.adb [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 9733411e8431eb854607a9db1c70cc011f0d60f1..253893342803bd76418969b0938a47994759772e 100644 (file)
@@ -1,3 +1,9 @@
+2008-04-15  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-ssa-structalias.c (get_constraint_for_component_ref): Do not
+       punt for STRING_CST.
+       (get_constraint_for): Deal with STRING_CST here instead.
+
 2008-04-15  Richard Guenther  <rguenther@suse.de>
 
        * tree-ssa-propagate.c (substitute_and_fold): Substitute
index 64e45319fc2d59b50f3f3db7d68074bcd6fc8484..81940dafcdaf8cf16553f40fd111bcc85c0d8cd4 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-15  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/string_slice2.adb: New test.
+
 2008-04-15  Richard Guenther  <rguenther@suse.de>
 
        * gcc.dg/fold-compare-2.c: Adjust testcase.
diff --git a/gcc/testsuite/gnat.dg/string_slice2.adb b/gcc/testsuite/gnat.dg/string_slice2.adb
new file mode 100644 (file)
index 0000000..e9a9efa
--- /dev/null
@@ -0,0 +1,24 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+with Ada.Strings;
+with Ada.Strings.Fixed;
+
+procedure String_Slice2 is
+
+   package ASF renames Ada.Strings.Fixed;
+
+   Delete_String  : String(1..10);
+   Source_String2 : String(1..12) := "abcdefghijkl";
+
+begin
+
+   Delete_String := Source_String2(1..10);
+
+   ASF.Delete(Source  => Delete_String,
+              From    => 6,
+              Through => Delete_String'Last,
+              Justify => Ada.Strings.Left,
+              Pad     => 'x');
+
+end;
index cecafca673a225d241666dbcd59dd17c83881d23..6f6eff422dafb8d459265df4fe868f27de7ac8d5 100644 (file)
@@ -2657,11 +2657,6 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results)
 
   t = get_ref_base_and_extent (t, &bitpos, &bitsize, &bitmaxsize);
 
-  /* String constants are readonly, so there is nothing to really do
-     here.  */
-  if (TREE_CODE (t) == STRING_CST)
-    return;
-
   get_constraint_for (t, results);
   result = VEC_last (ce_s, *results);
   result->offset = bitpos;
@@ -2779,6 +2774,16 @@ get_constraint_for (tree t, VEC (ce_s, heap) **results)
       return;
     }
 
+  /* String constants are read-only.  */
+  if (TREE_CODE (t) == STRING_CST)
+    {
+      temp.var = readonly_id;
+      temp.type = SCALAR;
+      temp.offset = 0;
+      VEC_safe_push (ce_s, heap, *results, &temp);
+      return;
+    }
+
   switch (TREE_CODE_CLASS (TREE_CODE (t)))
     {
     case tcc_expression: