aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2011-11-04 16:31:18 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-11-04 16:31:18 +0000
commit92b4d64cd44cbf3ecdc9be35099ed8692e3fc7ab (patch)
tree651010f1242c854610454967e439f982e353b878 /gcc
parente4fe948a6e9049df934677fc95d78b11c5cff4bd (diff)
downloadgcc-92b4d64cd44cbf3ecdc9be35099ed8692e3fc7ab.zip
gcc-92b4d64cd44cbf3ecdc9be35099ed8692e3fc7ab.tar.gz
gcc-92b4d64cd44cbf3ecdc9be35099ed8692e3fc7ab.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/warn/Wconversion-null-3.C8
4 files changed, 21 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 01d2f91..47e79fe 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4d7facc..2bf22f9 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 02f400e..d5a6ea5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C b/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C
new file mode 100644
index 0000000..1942ee2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wconversion-null-3.C
@@ -0,0 +1,8 @@
+// PR c++/48420
+
+void foo(int* p);
+
+void bar() {
+ const bool kDebugMode = false;
+ foo(kDebugMode); // { dg-warning "converting 'false'" }
+}