OSDN Git Service

2005-04-25 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Apr 2005 18:08:35 +0000 (18:08 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Apr 2005 18:08:35 +0000 (18:08 +0000)
        PR C++/21188
        * g++.dg/opt/rtti2.C: New test.
2005-04-25  Andrew Pinski  <pinskia@physics.uc.edu>

        PR C++/21188
        * rtti.c (ifnonnull): Cast the zero comparison operand
        to the correct type.

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

gcc/cp/ChangeLog
gcc/cp/rtti.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/rtti2.C [new file with mode: 0644]

index 07f7daa..74b00a1 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR C++/21188
+       * rtti.c (ifnonnull): Cast the zero comparison operand
+       to the correct type.
+
 2005-04-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/20991
index 1cad0bd..bff6c95 100644 (file)
@@ -419,7 +419,8 @@ static tree
 ifnonnull (tree test, tree result)
 {
   return build3 (COND_EXPR, TREE_TYPE (result),
-                build2 (EQ_EXPR, boolean_type_node, test, integer_zero_node),
+                build2 (EQ_EXPR, boolean_type_node, test, 
+                        cp_convert (TREE_TYPE (test), integer_zero_node)),
                 cp_convert (TREE_TYPE (result), integer_zero_node),
                 result);
 }
index 479f1f4..10f42d1 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR C++/21188
+       * g++.dg/opt/rtti2.C: New test.
+
 2005-04-25  Paul Brook  <paul@codesourcery.com>
        Steven G. Kargl  <kargls@comcast.net>
 
diff --git a/gcc/testsuite/g++.dg/opt/rtti2.C b/gcc/testsuite/g++.dg/opt/rtti2.C
new file mode 100644 (file)
index 0000000..ebbe3cd
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+// We used to ICE in compare_values as the types for a comparison
+// were not the same kind of types.
+
+struct class1
+{
+  virtual ~class1 ();
+};
+struct class2 :  class1 { };
+
+void f(class1 * oo)
+{
+  class2 * oj = dynamic_cast <class2 *>(oo) ;
+  if (oj)
+    delete oo;
+}