aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/call.c
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2007-03-16 23:32:12 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2007-03-16 23:32:12 +0000
commit07231d4f834e1286c28f28bd18065fdde30912ba (patch)
tree5a95c9649676f7d06f094cc2fa3481529f14eef5 /gcc/cp/call.c
parentaefd26064caa4f8e041540679169265d74e8f3fd (diff)
downloadgcc-07231d4f834e1286c28f28bd18065fdde30912ba.zip
gcc-07231d4f834e1286c28f28bd18065fdde30912ba.tar.gz
gcc-07231d4f834e1286c28f28bd18065fdde30912ba.tar.bz2
invoke.texi (-Wconversion): Document warnings specific to C++.
2007-03-16 Manuel Lopez-Ibanez <manu@gcc.gnu.org> * doc/invoke.texi (-Wconversion): Document warnings specific to C++. * c-common.c (convert_and_check): Move warning logic to... (warnings_for_convert_and_check): ...here. Define. * c-common.h (warnings_for_convert_and_check): Declare. cp/ * cvt.c (cp_convert_and_check) : Define. * cp-tree.h (cp_convert_and_check): Declare. * call.c (convert_conversion_warnings): Rename to conversion_null_warnings. The warning for floating-point to integer is handled by convert_and_check in convert_like_real. (convert_like_real): convert_conversion_warnings was renamed as conversion_null_warnings. * typeck.c (build_binary_op): Use cp_convert_and_check to warn for overflow and changes of value during conversion. testsuite/ * g++.dg/warn/Wconversion-integer.C: New * g++.dg/warn/Wconversion-real.C: New. * g++.dg/warn/Wconversion-real-integer.C: New. * g++.dg/warn/conv2.C: Updated. From-SVN: r123005
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r--gcc/cp/call.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 9d25298..8218ed4 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4245,11 +4245,12 @@ build_temp (tree expr, tree type, int flags,
return expr;
}
-/* Perform warnings about conversion of EXPR to type TOTYPE.
+/* Perform warnings about peculiar, but valid, conversions from/to NULL.
+ EXPR is implicitly converted to type TOTYPE.
FN and ARGNUM are used for diagnostics. */
static void
-convert_conversion_warnings (tree totype, tree expr, tree fn, int argnum)
+conversion_null_warnings (tree totype, tree expr, tree fn, int argnum)
{
tree t = non_reference (totype);
@@ -4263,19 +4264,8 @@ convert_conversion_warnings (tree totype, tree expr, tree fn, int argnum)
warning (OPT_Wconversion, "converting to non-pointer type %qT from NULL", t);
}
- /* Warn about assigning a floating-point type to an integer type. */
- if (TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
- && TREE_CODE (t) == INTEGER_TYPE)
- {
- if (fn)
- warning (OPT_Wconversion, "passing %qT for argument %P to %qD",
- TREE_TYPE (expr), argnum, fn);
- else
- warning (OPT_Wconversion, "converting to %qT from %qT", t, TREE_TYPE (expr));
- }
-
/* Issue warnings if "false" is converted to a NULL pointer */
- if (expr == boolean_false_node && fn && POINTER_TYPE_P (t))
+ else if (expr == boolean_false_node && fn && POINTER_TYPE_P (t))
warning (OPT_Wconversion,
"converting %<false%> to pointer type for argument %P of %qD",
argnum, fn);
@@ -4328,7 +4318,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
}
if (issue_conversion_warnings)
- convert_conversion_warnings (totype, expr, fn, argnum);
+ conversion_null_warnings (totype, expr, fn, argnum);
switch (convs->kind)
{
@@ -4415,7 +4405,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
expr = convert_like_real (convs->u.next, expr, fn, argnum,
convs->kind == ck_ref_bind ? -1 : 1,
- /*issue_conversion_warnings=*/false,
+ convs->kind == ck_ref_bind ? issue_conversion_warnings : false,
c_cast_p);
if (expr == error_mark_node)
return error_mark_node;