OSDN Git Service

2004-12-13 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2004 02:21:56 +0000 (02:21 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2004 02:21:56 +0000 (02:21 +0000)
        PR c++/18968
        * g++.dg/opt/pr18968.C: New test.

2004-12-13  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/18968
        * class.c (build_base_path): Convert the zero constant to the correct
        type when comparing.

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

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

index 71cce5f..a90ffec 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-13  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18968
+       * class.c (build_base_path): Convert the zero constant to the correct
+       type when comparing.
+
 2004-12-13  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/18925
index f7e5c7b..9625acc 100644 (file)
@@ -295,8 +295,11 @@ build_base_path (enum tree_code code,
 
   /* Now that we've saved expr, build the real null test.  */
   if (null_test)
-    null_test = fold (build2 (NE_EXPR, boolean_type_node,
-                             expr, integer_zero_node));
+    {
+      tree zero = cp_convert (TREE_TYPE (expr), integer_zero_node);
+      null_test = fold (build2 (NE_EXPR, boolean_type_node,
+                               expr, zero));
+    }
 
   /* If this is a simple base reference, express it as a COMPONENT_REF.  */
   if (code == PLUS_EXPR && !virtual_access
index 957c5eb..6b23ef1 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-13  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18968
+       * g++.dg/opt/pr18968.C: New test.
+
 2004-12-13  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/18925
diff --git a/gcc/testsuite/g++.dg/opt/pr18968.C b/gcc/testsuite/g++.dg/opt/pr18968.C
new file mode 100644 (file)
index 0000000..cce73b5
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-options "-O1" }
+struct X
+{
+  int i;
+};
+struct Y : virtual X {};
+struct Z : Y {};
+struct A
+{
+  Z* p;
+  A();
+};
+A::A() : p(0)
+{
+  ((X*)(Y*)p)->i++;
+}
+