This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[3.4 PATCH] Fix PR c++/19666


Hi!

This is a regression from GCC 3.2.x and fixed again on the trunk by
Andrew's patch.  I have bootstrapped/regtested this on
{i386,x86_64,ia64,ppc,ppc64,s390,s390x}-redhat-linux, ok for
gcc-3_4-branch?

2005-02-11  Jakub Jelinek  <jakub@redhat.com>

	PR c++/19666
	2004-06-08  Andrew Pinski  <pinskia@physics.uc.edu>
	* fold-const.c (fold_convert): Treat OFFSET_TYPE like
	POINTER_TYPE and INTEGER_TYPE.

	* gcc/testsuite/g++.dg/other/ptrmem6.C: New test.

--- gcc/fold-const.c	7 Jun 2004 20:50:09 -0000	1.388
+++ gcc/fold-const.c	9 Jun 2004 15:32:33 -0000	1.389
@@ -1911,7 +1911,8 @@ fold_convert (tree type, tree arg)
   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig))
     return fold (build1 (NOP_EXPR, type, arg));
 
-  if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
+  if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)
+      || TREE_CODE (type) == OFFSET_TYPE)
     {
       if (TREE_CODE (arg) == INTEGER_CST)
 	{
@@ -1919,7 +1920,8 @@ fold_convert (tree type, tree arg)
 	  if (tem != NULL_TREE)
 	    return tem;
 	}
-      if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig))
+      if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig)
+	  || TREE_CODE (orig) == OFFSET_TYPE)
         return fold (build1 (NOP_EXPR, type, arg));
       if (TREE_CODE (orig) == COMPLEX_TYPE)
 	{
--- gcc/testsuite/g++.dg/other/ptrmem6.C	2005-01-27 14:27:08.338732320 +0100
+++ gcc/testsuite/g++.dg/other/ptrmem6.C	2005-02-10 15:57:25.300924879 +0100
@@ -0,0 +1,10 @@
+// PR c++/19666
+// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+// { dg-do compile }
+
+struct A { int i; };
+
+int foo (A *p)
+{
+  return &p->i - &(p->*&A::i);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]