Commit 92b4d64c by Paolo Carlini Committed by Paolo Carlini

re PR c++/48420 (Missed -Wconversion-null warning when passing const bool to T*)

/cp
2011-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48420
	* call.c (conversion_null_warnings): For 'false' to NULL pointer,
	just check that TREE_TYPE (expr) is a BOOLEAN_TYPE.

/testsuite
2011-11-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/48420
	* g++.dg/warn/Wconversion-null-3.C: New.

From-SVN: r180963
parent e4fe948a
2011-11-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/48420
* call.c (conversion_null_warnings): For 'false' to NULL pointer,
just check that TREE_TYPE (expr) is a BOOLEAN_TYPE.
2011-11-04 Ed Smith-Rowland <3dw4rd@verizon.net>
PR c++/50941
......
......@@ -5544,7 +5544,8 @@ conversion_null_warnings (tree totype, tree expr, tree fn, int argnum)
}
/* Issue warnings if "false" is converted to a NULL pointer */
else if (expr == boolean_false_node && TYPE_PTR_P (totype))
else if (TREE_CODE (TREE_TYPE (expr)) == BOOLEAN_TYPE
&& TYPE_PTR_P (totype))
{
if (fn)
warning_at (input_location, OPT_Wconversion_null,
......
2011-11-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/48420
* g++.dg/warn/Wconversion-null-3.C: New.
2011-11-04 Ed Smith-Rowland <3dw4rd@verizon.net>
PR c++/50941
......
// PR c++/48420
void foo(int* p);
void bar() {
const bool kDebugMode = false;
foo(kDebugMode); // { dg-warning "converting 'false'" }
}
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