https://gcc.gnu.org/g:364d903a19462617fb25c714e002a261f094d30a

commit 364d903a19462617fb25c714e002a261f094d30a
Author: Mikael Morin <[email protected]>
Date:   Thu Oct 9 12:15:25 2025 +0200

    gimple-simulate: prise en charge initialisation chaînes de caractères

Diff:
---
 gcc/gimple-simulate.cc | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gcc/gimple-simulate.cc b/gcc/gimple-simulate.cc
index 7ed37673660f..d980d62ee402 100644
--- a/gcc/gimple-simulate.cc
+++ b/gcc/gimple-simulate.cc
@@ -2022,6 +2022,18 @@ simul_valueize (tree t)
 }
 
 
+static void
+set_cst_array_elem_at (data_value &result, tree elt_type, int index, int value)
+{
+  unsigned elt_size = get_constant_type_size (elt_type);
+
+  wide_int val = wi::uhwi (value, elt_size);
+  data_value elt_val (elt_size);
+  elt_val.set_known (val);
+  result.set_at (elt_val, index * elt_size);
+}
+
+
 /* Evaluate the expression EXPR using the values currently stored in
    accessible variables and allocated storages and return the resulting value.
    */
@@ -2157,6 +2169,20 @@ simul_scope::evaluate (tree expr) const
        return result;
       }
 
+    case STRING_CST:
+      {
+       tree expr_type = TREE_TYPE (expr);
+       data_value result (expr_type);
+       tree elt_type = TREE_TYPE (expr_type);
+
+       int len = TREE_STRING_LENGTH (expr);
+       const char *str = TREE_STRING_POINTER (expr);
+       for (int i = 0; i < len; ++i)
+         set_cst_array_elem_at (result, elt_type, i, str[i]);
+       set_cst_array_elem_at (result, elt_type, len, 0);
+       return result;
+      }
+
     case CONSTRUCTOR:
       return evaluate_constructor (expr);

Reply via email to