diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/call.c | 7 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 9 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 9 |
4 files changed, 26 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 541e725e..67dd067 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2012-04-30 Dodji Seketeli <dodji@redhat.com> + + Make conversion warnings work on NULL with -ftrack-macro-expansion + * call.c (conversion_null_warnings): Use the new + expansion_point_location_if_in_system_header. + * cvt.c (build_expr_type_conversion): Likewise. + * typeck.c (cp_build_binary_op): Likewise. + 2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org> * typeck.c (convert_for_assignment): Replace diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 2207f42..98d32c3 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5598,12 +5598,15 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum) if (expr == null_node && TREE_CODE (totype) != BOOLEAN_TYPE && ARITHMETIC_TYPE_P (totype)) { + source_location loc = + expansion_point_location_if_in_system_header (input_location); + if (fn) - warning_at (input_location, OPT_Wconversion_null, + warning_at (loc, OPT_Wconversion_null, "passing NULL to non-pointer argument %P of %qD", argnum, fn); else - warning_at (input_location, OPT_Wconversion_null, + warning_at (loc, OPT_Wconversion_null, "converting to non-pointer type %qT from NULL", totype); } diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 3dab372..49ba38a 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1472,8 +1472,13 @@ build_expr_type_conversion (int desires, tree expr, bool complain) if (expr == null_node && (desires & WANT_INT) && !(desires & WANT_NULL)) - warning_at (input_location, OPT_Wconversion_null, - "converting NULL to non-pointer type"); + { + source_location loc = + expansion_point_location_if_in_system_header (input_location); + + warning_at (loc, OPT_Wconversion_null, + "converting NULL to non-pointer type"); + } basetype = TREE_TYPE (expr); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 142402a..4f1e965 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3838,9 +3838,12 @@ cp_build_binary_op (location_t location, || (!null_ptr_cst_p (orig_op1) && !TYPE_PTR_P (type1) && !TYPE_PTR_TO_MEMBER_P (type1))) && (complain & tf_warning)) - /* Some sort of arithmetic operation involving NULL was - performed. */ - warning (OPT_Wpointer_arith, "NULL used in arithmetic"); + { + source_location loc = + expansion_point_location_if_in_system_header (input_location); + + warning_at (loc, OPT_Wpointer_arith, "NULL used in arithmetic"); + } switch (code) { |