aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgsvelto <gsvelto@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-08 19:18:55 +0000
committergsvelto <gsvelto@138bc75d-0d04-0410-961f-82ee72b054a4>2009-07-08 19:18:55 +0000
commit25612d71517ce0faca48ff6cc8816e5d3371531c (patch)
tree8cddebb64f0341eea4543cbe633b2824a8b99440
parent3d1d9146cb406bf63c126360e9934ffbedac0a0e (diff)
Resolved a problem with string initializers, this also quiets a warning.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/st/cli-be@149386 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/config/cil32/cil-refs.c16
-rw-r--r--gcc/config/cil32/gimple-to-cil.c16
2 files changed, 23 insertions, 9 deletions
diff --git a/gcc/config/cil32/cil-refs.c b/gcc/config/cil32/cil-refs.c
index f260fe1a3be..d02e6852808 100644
--- a/gcc/config/cil32/cil-refs.c
+++ b/gcc/config/cil32/cil-refs.c
@@ -146,10 +146,12 @@ static hashval_t assembly_hash (const void *ptr)
static int assembly_eq (const void *ptr1, const void *ptr2)
{
- const char *str1 = TREE_STRING_POINTER ((const_tree) ptr1);
- const char *str2 = TREE_STRING_POINTER ((const_tree) ptr2);
+ const_tree str1 = ((const_tree) ptr1);
+ const_tree str2 = ((const_tree) ptr2);
- return str1 == str2;
+ return (TREE_STRING_LENGTH (str1) == TREE_STRING_LENGTH (str2))
+ && ! memcmp (TREE_STRING_POINTER (str1), TREE_STRING_POINTER (str2),
+ TREE_STRING_LENGTH (str1));
}
/* Add a referenced assembly to the list of pending assemblies if it is not
@@ -880,10 +882,12 @@ str_ref_hash (const void *ptr)
static int
str_ref_eq (const void *ptr1, const void *ptr2)
{
- const char *str1 = TREE_STRING_POINTER (((const_str_ref) ptr1)->cst);
- const char *str2 = TREE_STRING_POINTER (((const_str_ref) ptr2)->cst);
+ const_tree str1 = ((const_str_ref) ptr1)->cst;
+ const_tree str2 = ((const_str_ref) ptr2)->cst;
- return str1 == str2;
+ return (TREE_STRING_LENGTH (str1) == TREE_STRING_LENGTH (str2))
+ && ! memcmp (TREE_STRING_POINTER (str1), TREE_STRING_POINTER (str2),
+ TREE_STRING_LENGTH (str1));
}
/* Mark the string represented by tree STR as referenced. If an identical
diff --git a/gcc/config/cil32/gimple-to-cil.c b/gcc/config/cil32/gimple-to-cil.c
index d6c707b9776..6881893b99a 100644
--- a/gcc/config/cil32/gimple-to-cil.c
+++ b/gcc/config/cil32/gimple-to-cil.c
@@ -716,10 +716,20 @@ expand_init_to_cil_seq1 (tree decl, tree init, cil_seq seq1, bool cleared,
{
case STRING_CST:
{
- if (TREE_STRING_LENGTH (init) < size)
- size = TREE_STRING_LENGTH (init);
-
csi = csi_last (seq1);
+
+ if ((unsigned HOST_WIDE_INT) TREE_STRING_LENGTH (init) < size)
+ {
+ size = TREE_STRING_LENGTH (init);
+ decl_size = build_int_cst (TREE_TYPE (decl_size), size);
+
+ if (! cleared)
+ {
+ gen_initblk (&csi, build_fold_addr_expr (decl),
+ integer_zero_node, decl_size);
+ }
+ }
+
gen_cpblk (&csi, build_fold_addr_expr (decl),
build_fold_addr_expr (init), decl_size);
memcpy(le_image, TREE_STRING_POINTER (init), size);