This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix ACATS cxa4005 failure at -O


Hi,

tree-ssa-structalias.c:do_structure_copy aborts on

  delete_string ={v} "abcdefghijkl"[1 ...]{lb: 1 sz: 1};

which is an ARRAY_RANGE_REF of a STRING_CST because no constraint is returned 
for the RHS and the code expects one:

  get_constraint_for (lhsop, &lhsc);
  get_constraint_for (rhsop, &rhsc);
  gcc_assert (VEC_length (ce_s, lhsc) == 1);
  gcc_assert (VEC_length (ce_s, rhsc) == 1);

This stems from get_constraint_for_component_ref:

  /* String constants are readonly, so there is nothing to really do
     here.  */
  if (TREE_CODE (t) == STRING_CST)
    return;

The proposed fix is to return { readonly_id, SCALAR, 0 } as the constraint for 
STRING_CST instead.  But other suggestions are welcome. :-)

Tested on i586-suse-linux, OK for mainline?


2008-04-09  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-09  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/string_slice2.adb: New test.


-- 
Eric Botcazou
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 134131)
+++ tree-ssa-structalias.c	(working copy)
@@ -2657,11 +2657,6 @@ get_constraint_for_component_ref (tree t
 
   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, h
       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:
-- { 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]