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]

C++ PATCH for C++/37016


The tree-ssa patch fixes this bug, but it also seemed unnecessary to have TYPE_STRUCTURAL_EQUALITY_P set for pmf types, so I tried to set up TYPE_CANONICAL for them. Turned out to not be as much of a nightmare as the comment warned.

Tested x86_64-pc-linux-gnu, applied to trunk. I'm not going to apply this to 4.3 unless people ask for it, since the other patch already fixes the bug.


2008-08-05  Jason Merrill  <jason@redhat.com>

	PR c++/37016
	* decl.c (build_ptrmemfunc_type): Don't require structural 
	comparison of PMF types.
	* tree.c (cp_build_qualified_type_real): Don't clear
	a valid TYPE_PTRMEMFUNC_TYPE.
	* typeck.c (cp_build_unary_op): Still do build_ptrmemfunc in 
	templates.

Index: typeck.c
===================================================================
*** typeck.c	(revision 138755)
--- typeck.c	(working copy)
*************** cp_build_unary_op (enum tree_code code, 
*** 4642,4656 ****
  
        /* In a template, we are processing a non-dependent expression
  	 so we can just form an ADDR_EXPR with the correct type.  */
!       if (processing_template_decl)
! 	{
! 	  val = build_address (arg);
! 	  if (TREE_CODE (arg) == OFFSET_REF)
! 	    PTRMEM_OK_P (val) = PTRMEM_OK_P (arg);
! 	  return val;
! 	}
! 
!       if (TREE_CODE (arg) != COMPONENT_REF)
  	{
  	  val = build_address (arg);
  	  if (TREE_CODE (arg) == OFFSET_REF)
--- 4642,4648 ----
  
        /* In a template, we are processing a non-dependent expression
  	 so we can just form an ADDR_EXPR with the correct type.  */
!       if (processing_template_decl || TREE_CODE (arg) != COMPONENT_REF)
  	{
  	  val = build_address (arg);
  	  if (TREE_CODE (arg) == OFFSET_REF)
Index: decl.c
===================================================================
*** decl.c	(revision 138755)
--- decl.c	(working copy)
*************** build_ptrmemfunc_type (tree type)
*** 6961,6976 ****
        TYPE_MAIN_VARIANT (t) = unqualified_variant;
        TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (unqualified_variant);
        TYPE_NEXT_VARIANT (unqualified_variant) = t;
      }
  
    /* Cache this pointer-to-member type so that we can find it again
       later.  */
    TYPE_SET_PTRMEMFUNC_TYPE (type, t);
  
!   /* Managing canonical types for the RECORD_TYPE behind a
!      pointer-to-member function is a nightmare, so use structural
!      equality for now.  */
!   SET_TYPE_STRUCTURAL_EQUALITY (t);
  
    return t;
  }
--- 6961,6977 ----
        TYPE_MAIN_VARIANT (t) = unqualified_variant;
        TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (unqualified_variant);
        TYPE_NEXT_VARIANT (unqualified_variant) = t;
+       TREE_TYPE (TYPE_BINFO (t)) = t;
      }
  
    /* Cache this pointer-to-member type so that we can find it again
       later.  */
    TYPE_SET_PTRMEMFUNC_TYPE (type, t);
  
!   if (TYPE_STRUCTURAL_EQUALITY_P (type))
!     SET_TYPE_STRUCTURAL_EQUALITY (t);
!   else if (TYPE_CANONICAL (type) != type)
!     TYPE_CANONICAL (t) = build_ptrmemfunc_type (TYPE_CANONICAL (type));
  
    return t;
  }
Index: tree.c
===================================================================
*** tree.c	(revision 138755)
--- tree.c	(working copy)
*************** cp_build_qualified_type_real (tree type,
*** 873,879 ****
       between the unqualified and qualified types.  */
    if (result != type
        && TREE_CODE (type) == POINTER_TYPE
!       && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
      TYPE_LANG_SPECIFIC (result) = NULL;
  
    return result;
--- 873,880 ----
       between the unqualified and qualified types.  */
    if (result != type
        && TREE_CODE (type) == POINTER_TYPE
!       && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
!       && TYPE_LANG_SPECIFIC (result) == TYPE_LANG_SPECIFIC (type))
      TYPE_LANG_SPECIFIC (result) = NULL;
  
    return result;

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