{
/* C_STRLEN will return NULL and set DECL in the info
structure if EXP references a unterminated array. */
- c_strlen_data data = { };
- tree len = c_strlen (exp, 1, &data);
- if (len == NULL_TREE && data.len && data.decl)
+ c_strlen_data lendata = { };
+ tree len = c_strlen (exp, 1, &lendata);
+ if (len == NULL_TREE && lendata.len && lendata.decl)
{
if (size)
{
- len = data.len;
- if (data.off)
+ len = lendata.len;
+ if (lendata.off)
{
- /* Constant offsets are already accounted for in data.len, but
- not in a SSA_NAME + CST expression. */
- if (TREE_CODE (data.off) == INTEGER_CST)
+ /* Constant offsets are already accounted for in LENDATA.MINLEN,
+ but not in a SSA_NAME + CST expression. */
+ if (TREE_CODE (lendata.off) == INTEGER_CST)
*exact = true;
- else if (TREE_CODE (data.off) == PLUS_EXPR
- && TREE_CODE (TREE_OPERAND (data.off, 1)) == INTEGER_CST)
+ else if (TREE_CODE (lendata.off) == PLUS_EXPR
+ && TREE_CODE (TREE_OPERAND (lendata.off, 1)) == INTEGER_CST)
{
/* Subtract the offset from the size of the array. */
*exact = false;
- tree temp = TREE_OPERAND (data.off, 1);
+ tree temp = TREE_OPERAND (lendata.off, 1);
temp = fold_convert (ssizetype, temp);
len = fold_build2 (MINUS_EXPR, ssizetype, len, temp);
}
*size = len;
}
- return data.decl;
+ return lendata.decl;
}
return NULL_TREE;
/* FIXME: Change c_strlen() to return sizetype instead of ssizetype
so these conversions aren't necessary. */
- c_strlen_data data { };
- tree len = c_strlen (src, 0, &data, 1);
+ c_strlen_data lendata = { };
+ tree len = c_strlen (src, 0, &lendata, 1);
if (len)
len = fold_convert_loc (loc, TREE_TYPE (bound), len);
strnlen (&a[i], sizeof a)
where the value of i is unknown. Unless i's value is
zero, the call is unsafe because the bound is greater. */
- data.decl = unterminated_array (src, &len, &exact);
- if (!data.decl)
+ lendata.decl = unterminated_array (src, &len, &exact);
+ if (!lendata.decl)
return NULL_RTX;
}
- if (data.decl
+ if (lendata.decl
&& !TREE_NO_WARNING (exp)
&& ((tree_int_cst_lt (len, bound))
|| !exact))
"of at most %E of unterminated array"),
exp, func, bound, len))
{
- inform (DECL_SOURCE_LOCATION (data.decl),
+ inform (DECL_SOURCE_LOCATION (lendata.decl),
"referenced argument declared here");
TREE_NO_WARNING (exp) = true;
return NULL_RTX;
bool exact = true;
if (!len || TREE_CODE (len) != INTEGER_CST)
{
- data.decl = unterminated_array (src, &len, &exact);
- if (!data.decl)
+ lendata.decl = unterminated_array (src, &len, &exact);
+ if (!lendata.decl)
return NULL_RTX;
}
- if (data.decl
+ if (lendata.decl
&& !TREE_NO_WARNING (exp)
&& (wi::ltu_p (wi::to_wide (len), min)
|| !exact))
"the size of at most %E of unterminated array"),
exp, func, min.to_uhwi (), max.to_uhwi (), len))
{
- inform (DECL_SOURCE_LOCATION (data.decl),
+ inform (DECL_SOURCE_LOCATION (lendata.decl),
"referenced argument declared here");
TREE_NO_WARNING (exp) = true;
}
}
- if (data.decl)
+ if (lendata.decl)
return NULL_RTX;
if (wi::gtu_p (min, wi::to_wide (len)))
compile-time, not an expression containing a string. This is
because the latter will potentially produce pessimized code
when used to produce the return value. */
- c_strlen_data data = { };
+ c_strlen_data lendata = { };
if (!c_getstr (src, NULL)
- || !(len = c_strlen (src, 0, &data, 1)))
+ || !(len = c_strlen (src, 0, &lendata, 1)))
return expand_movstr (dst, src, target,
/*retmode=*/ RETURN_END_MINUS_ONE);
- if (data.decl && !TREE_NO_WARNING (exp))
- warn_string_no_nul (EXPR_LOCATION (exp), "stpcpy", src, data.decl);
+ if (lendata.decl && !TREE_NO_WARNING (exp))
+ warn_string_no_nul (EXPR_LOCATION (exp), "stpcpy", src, lendata.decl);
lenp1 = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1));
ret = expand_builtin_mempcpy_args (dst, src, lenp1,
return NULL_TREE;
else
{
- c_strlen_data data = { };
- tree len = c_strlen (arg, 0, &data);
+ c_strlen_data lendata = { };
+ tree len = c_strlen (arg, 0, &lendata);
if (len)
return fold_convert_loc (loc, type, len);
- if (!data.decl)
- c_strlen (arg, 1, &data);
+ if (!lendata.decl)
+ c_strlen (arg, 1, &lendata);
- if (data.decl)
+ if (lendata.decl)
{
if (EXPR_HAS_LOCATION (arg))
loc = EXPR_LOCATION (arg);
else if (loc == UNKNOWN_LOCATION)
loc = input_location;
- warn_string_no_nul (loc, "strlen", arg, data.decl);
+ warn_string_no_nul (loc, "strlen", arg, lendata.decl);
}
return NULL_TREE;
}
else
{
- c_strlen_data data = { };
- val = c_strlen (arg, 1, &data, eltsize);
+ c_strlen_data lendata = { };
+ val = c_strlen (arg, 1, &lendata, eltsize);
/* If we potentially had a non-terminated string, then
bubble that information up to the caller. */
- if (!val && data.decl)
+ if (!val && lendata.decl)
{
- *nonstr = data.decl;
- *minlen = data.len;
- *maxlen = data.len;
+ *nonstr = lendata.decl;
+ *minlen = lendata.len;
+ *maxlen = lendata.len;
return type == 0 ? false : true;
}
}
if (TREE_CODE (arg) == ARRAY_REF)
{
- tree type = TREE_TYPE (TREE_OPERAND (arg, 0));
+ tree optype = TREE_TYPE (TREE_OPERAND (arg, 0));
/* Determine the "innermost" array type. */
- while (TREE_CODE (type) == ARRAY_TYPE
- && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
- type = TREE_TYPE (type);
+ while (TREE_CODE (optype) == ARRAY_TYPE
+ && TREE_CODE (TREE_TYPE (optype)) == ARRAY_TYPE)
+ optype = TREE_TYPE (optype);
/* Avoid arrays of pointers. */
- tree eltype = TREE_TYPE (type);
- if (TREE_CODE (type) != ARRAY_TYPE
+ tree eltype = TREE_TYPE (optype);
+ if (TREE_CODE (optype) != ARRAY_TYPE
|| !INTEGRAL_TYPE_P (eltype))
return false;
- val = TYPE_SIZE_UNIT (type);
+ /* Fail when the array bound is unknown or zero. */
+ val = TYPE_SIZE_UNIT (optype);
if (!val || integer_zerop (val))
return false;
*minlen = ssize_int (0);
if (TREE_CODE (TREE_OPERAND (arg, 0)) == COMPONENT_REF
- && type == TREE_TYPE (TREE_OPERAND (arg, 0))
+ && optype == TREE_TYPE (TREE_OPERAND (arg, 0))
&& array_at_struct_end_p (TREE_OPERAND (arg, 0)))
*flexp = true;
}
if (array_at_struct_end_p (arg))
*flexp = true;
- arg = TREE_OPERAND (arg, 1);
+ tree fld = TREE_OPERAND (arg, 1);
- tree type = TREE_TYPE (arg);
+ tree optype = TREE_TYPE (fld);
- while (TREE_CODE (type) == ARRAY_TYPE
- && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
- type = TREE_TYPE (type);
+ /* Determine the "innermost" array type. */
+ while (TREE_CODE (optype) == ARRAY_TYPE
+ && TREE_CODE (TREE_TYPE (optype)) == ARRAY_TYPE)
+ optype = TREE_TYPE (optype);
/* Fail when the array bound is unknown or zero. */
- val = TYPE_SIZE_UNIT (type);
+ val = TYPE_SIZE_UNIT (optype);
if (!val || integer_zerop (val))
return false;
val = fold_build2 (MINUS_EXPR, TREE_TYPE (val), val,