From bd1f29d927823c063ef88658743c274034fa801a Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 15 Apr 2008 18:22:51 +0000 Subject: [PATCH] tree-ssa-structalias.c (get_constraint_for_component_ref): Do not punt for STRING_CST. * 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 | 6 ++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/string_slice2.adb | 24 ++++++++++++++++++++++++ gcc/tree-ssa-structalias.c | 15 ++++++++++----- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/string_slice2.adb diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9733411e843..25389334280 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-04-15 Eric Botcazou + + * 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 * tree-ssa-propagate.c (substitute_and_fold): Substitute diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 64e45319fc2..81940dafcda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-04-15 Eric Botcazou + + * gnat.dg/string_slice2.adb: New test. + 2008-04-15 Richard Guenther * 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 index 00000000000..e9a9efaa132 --- /dev/null +++ b/gcc/testsuite/gnat.dg/string_slice2.adb @@ -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; diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index cecafca673a..6f6eff422da 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -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: