Commit 550dfbdc by Martin Sebor Committed by Martin Sebor

PR c/88091 - c-c++-common/Wconversion-real.c etc. FAIL

gcc/c/ChangeLog:

	PR c/88091
	* c-typeck.c (convert_argument): Add a parameter.  Adjust indentation.
	(convert_arguments): Add comments.  Pass additional argument to
	the function above.

From-SVN: r266634
parent 673670da
2018-11-29 Martin Sebor <msebor@redhat.com> 2018-11-29 Martin Sebor <msebor@redhat.com>
PR c/88091
* c-typeck.c (convert_argument): Add a parameter. Adjust indentation.
(convert_arguments): Add comments. Pass additional argument to
the function above.
2018-11-29 Martin Sebor <msebor@redhat.com>
PR c/88172 PR c/88172
PR testsuite/88208 PR testsuite/88208
* c-decl.c (declspec_add_alignas): Adjust call to check_user_alignment. * c-decl.c (declspec_add_alignas): Adjust call to check_user_alignment.
......
...@@ -3186,28 +3186,34 @@ c_build_function_call_vec (location_t loc, vec<location_t> arg_loc, ...@@ -3186,28 +3186,34 @@ c_build_function_call_vec (location_t loc, vec<location_t> arg_loc,
/* Helper for convert_arguments called to convert the VALue of argument /* Helper for convert_arguments called to convert the VALue of argument
number ARGNUM from ORIGTYPE to the corresponding parameter number number ARGNUM from ORIGTYPE to the corresponding parameter number
PARMNUL and TYPE. */ PARMNUM and TYPE.
PLOC is the location where the conversion is being performed.
FUNCTION and FUNDECL are the same as in convert_arguments.
VALTYPE is the original type of VAL before the conversion and,
for EXCESS_PRECISION_EXPR, the operand of the expression.
NPC is true if VAL represents the null pointer constant (VAL itself
will have been folded to an integer constant).
RNAME is the same as FUNCTION except in Objective C when it's
the function selector.
EXCESS_PRECISION is true when VAL was originally represented
as EXCESS_PRECISION_EXPR.
WARNOPT is the same as in convert_for_assignment. */
static tree static tree
convert_argument (location_t ploc, tree function, tree fundecl, convert_argument (location_t ploc, tree function, tree fundecl,
tree type, tree origtype, tree val, bool npc, tree type, tree origtype, tree val, tree valtype,
tree rname, int parmnum, int argnum, bool npc, tree rname, int parmnum, int argnum,
bool excess_precision, int warnopt) bool excess_precision, int warnopt)
{ {
tree valtype = TREE_TYPE (val);
tree parmval;
/* Formal parm type is specified by a function prototype. */ /* Formal parm type is specified by a function prototype. */
if (type == error_mark_node || !COMPLETE_TYPE_P (type)) if (type == error_mark_node || !COMPLETE_TYPE_P (type))
{ {
error_at (ploc, "type of formal parameter %d is incomplete", error_at (ploc, "type of formal parameter %d is incomplete",
parmnum + 1); parmnum + 1);
parmval = val; return val;
} }
else
{
/* Optionally warn about conversions that differ from the default /* Optionally warn about conversions that differ from the default
conversions. */ conversions. */
if (warn_traditional_conversion || warn_traditional) if (warn_traditional_conversion || warn_traditional)
...@@ -3352,7 +3358,7 @@ convert_argument (location_t ploc, tree function, tree fundecl, ...@@ -3352,7 +3358,7 @@ convert_argument (location_t ploc, tree function, tree fundecl,
if (excess_precision) if (excess_precision)
val = build1 (EXCESS_PRECISION_EXPR, valtype, val); val = build1 (EXCESS_PRECISION_EXPR, valtype, val);
parmval = convert_for_assignment (ploc, ploc, type, tree parmval = convert_for_assignment (ploc, ploc, type,
val, origtype, ic_argpass, val, origtype, ic_argpass,
npc, fundecl, function, npc, fundecl, function,
parmnum + 1, warnopt); parmnum + 1, warnopt);
...@@ -3361,7 +3367,6 @@ convert_argument (location_t ploc, tree function, tree fundecl, ...@@ -3361,7 +3367,6 @@ convert_argument (location_t ploc, tree function, tree fundecl,
&& INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (type)
&& (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))) && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
parmval = default_conversion (parmval); parmval = default_conversion (parmval);
}
return parmval; return parmval;
} }
...@@ -3457,8 +3462,8 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist, ...@@ -3457,8 +3462,8 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
} }
} }
/* Scan the given expressions and types, producing individual /* Scan the given expressions (VALUES) and types (TYPELIST), producing
converted arguments. */ individual converted arguments. */
tree typetail, builtin_typetail, val; tree typetail, builtin_typetail, val;
for (typetail = typelist, for (typetail = typelist,
...@@ -3467,14 +3472,23 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist, ...@@ -3467,14 +3472,23 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
values && values->iterate (parmnum, &val); values && values->iterate (parmnum, &val);
++parmnum) ++parmnum)
{ {
/* The type of the function parameter (if it was declared with one). */
tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE; tree type = typetail ? TREE_VALUE (typetail) : NULL_TREE;
/* The type of the built-in function parameter (if the function
is a built-in). Used to detect type incompatibilities in
calls to built-ins declared without a prototype. */
tree builtin_type = (builtin_typetail tree builtin_type = (builtin_typetail
? TREE_VALUE (builtin_typetail) : NULL_TREE); ? TREE_VALUE (builtin_typetail) : NULL_TREE);
/* The original type of the argument being passed to the function. */
tree valtype = TREE_TYPE (val); tree valtype = TREE_TYPE (val);
/* The called function (or function selector in Objective C). */
tree rname = function; tree rname = function;
int argnum = parmnum + 1; int argnum = parmnum + 1;
const char *invalid_func_diag; const char *invalid_func_diag;
/* Set for EXCESS_PRECISION_EXPR arguments. */
bool excess_precision = false; bool excess_precision = false;
/* The value of the argument after conversion to the type
of the function parameter it is passed to. */
tree parmval; tree parmval;
/* Some __atomic_* builtins have additional hidden argument at /* Some __atomic_* builtins have additional hidden argument at
position 0. */ position 0. */
...@@ -3558,7 +3572,7 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist, ...@@ -3558,7 +3572,7 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
{ {
tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum]; tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
parmval = convert_argument (ploc, function, fundecl, type, origtype, parmval = convert_argument (ploc, function, fundecl, type, origtype,
val, npc, rname, parmnum, argnum, val, valtype, npc, rname, parmnum, argnum,
excess_precision, 0); excess_precision, 0);
} }
else if (promote_float_arg) else if (promote_float_arg)
...@@ -3610,7 +3624,8 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist, ...@@ -3610,7 +3624,8 @@ convert_arguments (location_t loc, vec<location_t> arg_loc, tree typelist,
above by applying default conversions instead. */ above by applying default conversions instead. */
tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum]; tree origtype = (!origtypes) ? NULL_TREE : (*origtypes)[parmnum];
convert_argument (ploc, function, fundecl, builtin_type, origtype, convert_argument (ploc, function, fundecl, builtin_type, origtype,
val, npc, rname, parmnum, argnum, excess_precision, val, valtype, npc, rname, parmnum, argnum,
excess_precision,
OPT_Wbuiltin_declaration_mismatch); OPT_Wbuiltin_declaration_mismatch);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment