Message ID | 4E918FED.4060002@oracle.com |
---|---|
State | New |
Headers | show |
Hmm, I guess it's unlikely that a conversion is going to hit both that warning and another one. OK. Jason
On 10/09/2011 11:40 PM, Jason Merrill wrote: > Hmm, I guess it's unlikely that a conversion is going to hit both that > warning and another one. OK. Wait...how about changing conversion_null_warnings to stop looking through references? Does that break anything? Jason
On 10/10/2011 12:41 AM, Jason Merrill wrote: > On 10/09/2011 11:40 PM, Jason Merrill wrote: >> Hmm, I guess it's unlikely that a conversion is going to hit both that >> warning and another one. OK. > Wait...how about changing conversion_null_warnings to stop looking > through references? Does that break anything? Let me check... Paolo.
On 10/10/2011 12:41 AM, Jason Merrill wrote: > On 10/09/2011 11:40 PM, Jason Merrill wrote: >> Hmm, I guess it's unlikely that a conversion is going to hit both that >> warning and another one. OK. > > Wait...how about changing conversion_null_warnings to stop looking > through references? Does that break anything? If I just do this (I hope it's what you had in mind): static void conversion_null_warnings (tree totype, tree expr, tree fn, int argnum) { - tree t = non_reference (totype); + tree t = totype; /*non_reference (totype); */ I see this failure, for sure: cpp0x/variadic111.C, that is: // PR c++/48424 // { dg-options -std=c++0x } template<typename... Args1> struct S { template<typename... Args2> void f(Args1... args1, Args2&&... args2) { } }; int main() { S<int, double> s; s.f(1,2.0,false,'a'); } triggers: variadic111.C:16:22: warning: converting ‘false’ to pointer type for argument 3 of ‘void S<Args1>::f(Args1 ..., Args2&& ...) [with Args2 = {bool, char}; Args1 = {int, double}]’ [-Wconversion-null] Also, tree-ssa/copyprop.C, for example. Paolo.
On 10/10/2011 12:44 AM, Paolo Carlini wrote: > If I just do this (I hope it's what you had in mind): > > - tree t = non_reference (totype); > + tree t = totype; /*non_reference (totype); */ > > variadic111.C:16:22: warning: converting ‘false’ to pointer type for > argument 3 of ‘void S<Args1>::f(Args1 ..., Args2&& ...) [with Args2 = > {bool, char}; Args1 = {int, double}]’ [-Wconversion-null] Hmm, need to also change POINTER_TYPE_P to TYPE_PTR_P. Jason
Index: call.c =================================================================== --- call.c (revision 179720) +++ call.c (working copy) @@ -5509,9 +5509,9 @@ build_temp (tree expr, tree type, int flags, /* Perform warnings about peculiar, but valid, conversions from/to NULL. EXPR is implicitly converted to type TOTYPE. - FN and ARGNUM are used for diagnostics. */ + FN and ARGNUM are used for diagnostics. Returns true if warned. */ -static void +static bool conversion_null_warnings (tree totype, tree expr, tree fn, int argnum) { tree t = non_reference (totype); @@ -5526,6 +5526,7 @@ conversion_null_warnings (tree totype, tree expr, else warning_at (input_location, OPT_Wconversion_null, "converting to non-pointer type %qT from NULL", t); + return true; } /* Issue warnings if "false" is converted to a NULL pointer */ @@ -5538,7 +5539,9 @@ conversion_null_warnings (tree totype, tree expr, else warning_at (input_location, OPT_Wconversion_null, "converting %<false%> to pointer type %qT", t); + return true; } + return false; } /* Perform the conversions in CONVS on the expression EXPR. FN and @@ -5624,8 +5627,9 @@ convert_like_real (conversion *convs, tree expr, t return cp_convert (totype, expr); } - if (issue_conversion_warnings && (complain & tf_warning)) - conversion_null_warnings (totype, expr, fn, argnum); + if (issue_conversion_warnings && (complain & tf_warning) + && conversion_null_warnings (totype, expr, fn, argnum)) + issue_conversion_warnings = false; switch (convs->kind) {