aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2007-11-23 19:15:09 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2007-11-23 19:15:09 +0000
commit6ca39fcbf6eb51d39d84916a4c742e20bb2c91e0 (patch)
tree12066094a6cb3be14cb5a9561ed87af7a386beb5
parentf89935ed1786b2bc9e4d3fba30387343a4c4f312 (diff)
downloadgcc-6ca39fcbf6eb51d39d84916a4c742e20bb2c91e0.zip
gcc-6ca39fcbf6eb51d39d84916a4c742e20bb2c91e0.tar.gz
gcc-6ca39fcbf6eb51d39d84916a4c742e20bb2c91e0.tar.bz2
re PR c++/5310 (Weird warnings about using (int)NULL)
2007-11-23 Mark Mitchell <mark@codesourcery.com> Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/5310 cp/ * call.c (convert_like_real): Build a zero constant when __null is converted to an integer type. testsuite/ * g++.dg/warn/pr5310.C: New. * g++.dg/warn/pr33160.C: New Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org> From-SVN: r130381
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g++.dg/warn/pr33160.C12
-rw-r--r--gcc/testsuite/g++.dg/warn/pr5310.C11
5 files changed, 45 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 48119fb..0aff9b1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-23 Mark Mitchell <mark@codesourcery.com>
+ Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR c++/5310
+ * call.c (convert_like_real): Build a zero constant when __null is
+ converted to an integer type.
+
2007-11-22 Jakub Jelinek <jakub@redhat.com>
PR c++/34094
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ecb8858..d240b85 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4420,7 +4420,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
about to bind it to a reference, in which case we need to
leave it as an lvalue. */
if (inner >= 0)
- expr = decl_constant_value (expr);
+ {
+ expr = decl_constant_value (expr);
+ if (expr == null_node && INTEGRAL_TYPE_P (totype))
+ /* If __null has been converted to an integer type, we do not
+ want to warn about uses of EXPR as an integer, rather than
+ as a pointer. */
+ expr = build_int_cst (totype, 0);
+ }
return expr;
case ck_ambig:
/* Call build_user_type_conversion again for the error. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9f893c3..5e5578d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-23 Mark Mitchell <mark@codesourcery.com>
+ Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR c++/5310
+ * g++.dg/warn/pr5310.C: New.
+ * g++.dg/warn/pr33160.C: New.
+
2007-11-23 Richard Guenther <rguenther@suse.de>
Michael Matz <matz@suse.de>
diff --git a/gcc/testsuite/g++.dg/warn/pr33160.C b/gcc/testsuite/g++.dg/warn/pr33160.C
new file mode 100644
index 0000000..e463e2d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr33160.C
@@ -0,0 +1,12 @@
+// PR 33160
+// { dg-do compile }
+// { dg-options "-Wall -Wextra -Wpointer-arith -pedantic -Wconversion" }
+
+typedef int __attribute__((mode(pointer))) intptr_t;
+int foo(void)
+{
+ intptr_t t = 0;
+ if (t != ((intptr_t)__null)) t = 1;
+ return 0;
+}
+
diff --git a/gcc/testsuite/g++.dg/warn/pr5310.C b/gcc/testsuite/g++.dg/warn/pr5310.C
new file mode 100644
index 0000000..48a6006
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr5310.C
@@ -0,0 +1,11 @@
+// PR 5310
+// { dg-do compile }
+// { dg-options "-pedantic -Wall -Wextra -Wpointer-arith -Wconversion" }
+void foo (int);
+void foo (long);
+
+void bar()
+{
+ foo ((int)__null);
+ foo ((long)__null);
+}