+2018-10-29 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/56856
+ * c-common.c (check_function_sentinel): Call fold_for_warn on the
+ argument.
+ (check_function_restrict): Rename param "argarray" to
+ "unfolded_argarray", and make a copy named "argarray", calling
+ fold_for_warn on each argument.
+ (check_function_arguments): Add note about responsibility for
+ folding the arguments.
+
2018-10-17 Joseph Myers <joseph@codesourcery.com>
* c-common.c (flag_isoc2x): New variable.
}
/* Validate the sentinel. */
- sentinel = argarray[nargs - 1 - pos];
+ sentinel = fold_for_warn (argarray[nargs - 1 - pos]);
if ((!POINTER_TYPE_P (TREE_TYPE (sentinel))
|| !integer_zerop (sentinel))
/* Although __null (in C++) is only an integer we allow it
static bool
check_function_restrict (const_tree fndecl, const_tree fntype,
- int nargs, tree *argarray)
+ int nargs, tree *unfolded_argarray)
{
int i;
tree parms = TYPE_ARG_TYPES (fntype);
+ /* Call fold_for_warn on all of the arguments. */
+ auto_vec<tree> argarray (nargs);
+ for (i = 0; i < nargs; i++)
+ argarray.quick_push (fold_for_warn (unfolded_argarray[i]));
+
if (fndecl
&& TREE_CODE (fndecl) == FUNCTION_DECL)
{
if (POINTER_TYPE_P (type)
&& TYPE_RESTRICT (type)
&& !TYPE_READONLY (TREE_TYPE (type)))
- warned |= warn_for_restrict (i, argarray, nargs);
+ warned |= warn_for_restrict (i, argarray.address (), nargs);
}
for (i = 0; i < nargs; i++)
/* Check for valid arguments being passed to a function with FNTYPE.
There are NARGS arguments in the array ARGARRAY. LOC should be used
for diagnostics. Return true if either -Wnonnull or -Wrestrict has
- been issued. */
+ been issued.
+
+ The arguments in ARGARRAY may not have been folded yet (e.g. for C++,
+ to preserve location wrappers); checks that require folded arguments
+ should call fold_for_warn on them. */
bool
check_function_arguments (location_t loc, const_tree fndecl, const_tree fntype,
+2018-10-29 David Malcolm <dmalcolm@redhat.com>
+
+ PR c++/56856
+ * call.c (build_over_call): Eliminate the "arglocs" array, and the
+ call to maybe_constant_value when building "fargs".
+
2018-10-29 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (create_array_type_for_decl): Add location_t parameter
{
tree *fargs = (!nargs ? argarray
: (tree *) alloca (nargs * sizeof (tree)));
- auto_vec<location_t> arglocs (nargs);
for (j = 0; j < nargs; j++)
{
/* For -Wformat undo the implicit passing by hidden reference
&& TYPE_REF_P (TREE_TYPE (argarray[j])))
fargs[j] = TREE_OPERAND (argarray[j], 0);
else
- fargs[j] = maybe_constant_value (argarray[j]);
- arglocs.quick_push (EXPR_LOC_OR_LOC (argarray[j], input_location));
+ fargs[j] = argarray[j];
}
warned_p = check_function_arguments (input_location, fn, TREE_TYPE (fn),
- nargs, fargs, &arglocs);
+ nargs, fargs, NULL);
}
if (DECL_INHERITED_CTOR (fn))