aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-sprintf.c
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2018-08-16 22:38:04 +0000
committerJeff Law <law@gcc.gnu.org>2018-08-16 16:38:04 -0600
commit4148b00dbc46a461915602b2b3489d69fd211c22 (patch)
tree6824c0132908bd3df28f7e8852acad2c0f4eaafd /gcc/gimple-ssa-sprintf.c
parent5c6a2bf2720fd6412a2d63a3a82da5af0c18f824 (diff)
downloadgcc-4148b00dbc46a461915602b2b3489d69fd211c22.zip
gcc-4148b00dbc46a461915602b2b3489d69fd211c22.tar.gz
gcc-4148b00dbc46a461915602b2b3489d69fd211c22.tar.bz2
builtins.c (c_strlen): Add new parameter eltsize.
* builtins.c (c_strlen): Add new parameter eltsize. Use it for determining how to count the elements. * builtins.h (c_strlen): Adjust prototype. * expr.c (string_constant): Add new parameter mem_size. Set *mem_size appropriately. * expr.h (string_constant): Adjust protoype. * gimple-fold.c (get_range_strlen): Add new parameter eltsize. * gimple-fold.h (get_range_strlen): Adjust prototype. * gimple-ssa-sprintf.c (get_string_length): Add new parameter eltsize. (format_string): Call get_string_length with eltsize. From-SVN: r263607
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r--gcc/gimple-ssa-sprintf.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 5213e17..2431b52 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -2125,12 +2125,12 @@ format_floating (const directive &dir, tree arg, vr_values *)
Used by the format_string function below. */
static fmtresult
-get_string_length (tree str)
+get_string_length (tree str, unsigned eltsize)
{
if (!str)
return fmtresult ();
- if (tree slen = c_strlen (str, 1))
+ if (tree slen = c_strlen (str, 1, eltsize))
{
/* Simply return the length of the string. */
fmtresult res (tree_to_shwi (slen));
@@ -2143,7 +2143,7 @@ get_string_length (tree str)
aren't known to point any such arrays result in LENRANGE[1] set
to SIZE_MAX. */
tree lenrange[2];
- bool flexarray = get_range_strlen (str, lenrange);
+ bool flexarray = get_range_strlen (str, lenrange, eltsize);
if (lenrange [0] || lenrange [1])
{
@@ -2195,7 +2195,7 @@ get_string_length (tree str)
return res;
}
- return get_string_length (NULL_TREE);
+ return fmtresult ();
}
/* Return the minimum and maximum number of characters formatted
@@ -2274,7 +2274,8 @@ format_string (const directive &dir, tree arg, vr_values *)
fmtresult res;
/* Compute the range the argument's length can be in. */
- fmtresult slen = get_string_length (arg);
+ int count_by = dir.specifier == 'S' || dir.modifier == FMT_LEN_l ? 4 : 1;
+ fmtresult slen = get_string_length (arg, count_by);
if (slen.range.min == slen.range.max
&& slen.range.min < HOST_WIDE_INT_MAX)
{