OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Nov 2011 18:31:30 +0000 (18:31 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Nov 2011 18:31:30 +0000 (18:31 +0000)
2011-11-30  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51299
* rtti.c (ifnonnull): Use nullptr_node.
(build_dynamic_cast_1): Call cp_truthvalue_conversion instead
of c_common_truthvalue_conversion.

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

PR c++/51299
* g++.dg/warn/Wzero-as-null-pointer-constant-4.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181854 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/rtti.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-4.C [new file with mode: 0644]

index 0772ee9..42573ef 100644 (file)
@@ -1,3 +1,10 @@
+2011-11-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51299
+       * rtti.c (ifnonnull): Use nullptr_node.
+       (build_dynamic_cast_1): Call cp_truthvalue_conversion instead
+       of c_common_truthvalue_conversion.
+
 2011-11-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/51227
index 818b8d0..4494fdd 100644 (file)
@@ -503,8 +503,8 @@ ifnonnull (tree test, tree result)
 {
   return build3 (COND_EXPR, TREE_TYPE (result),
                 build2 (EQ_EXPR, boolean_type_node, test,
-                        cp_convert (TREE_TYPE (test), integer_zero_node)),
-                cp_convert (TREE_TYPE (result), integer_zero_node),
+                        cp_convert (TREE_TYPE (test), nullptr_node)),
+                cp_convert (TREE_TYPE (result), nullptr_node),
                 result);
 }
 
@@ -747,7 +747,7 @@ build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain)
              tree neq;
 
              result = save_expr (result);
-             neq = c_common_truthvalue_conversion (input_location, result);
+             neq = cp_truthvalue_conversion (result);
              return cp_convert (type,
                                 build3 (COND_EXPR, TREE_TYPE (result),
                                         neq, result, bad));
index 3d695a2..fb13fb5 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51299
+       * g++.dg/warn/Wzero-as-null-pointer-constant-4.C: New.
+
 2011-11-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/51247
diff --git a/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-4.C b/gcc/testsuite/g++.dg/warn/Wzero-as-null-pointer-constant-4.C
new file mode 100644 (file)
index 0000000..548caac
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/51299
+// { dg-options "-Wzero-as-null-pointer-constant" }
+
+class Base
+{
+  public:
+  virtual ~Base();
+};
+
+class Derived : public Base
+{
+};
+
+void foo(Base* b)
+{
+  Derived* d = dynamic_cast<Derived*>(b);
+}
+
+void bar(Base& b)
+{
+  Derived& d = dynamic_cast<Derived&>(b);
+}