diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ff23cdb5dd..8ece21d96f9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2008-08-05 Jason Merrill + + 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. + 2008-08-04 Jason Merrill PR c++/36963 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 1ed98eee4ff..69fa647881c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6961,16 +6961,17 @@ build_ptrmemfunc_type (tree type) 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); - /* 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); + 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; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 4114f868d41..ff19cd69d8b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -873,7 +873,8 @@ cp_build_qualified_type_real (tree type, between the unqualified and qualified types. */ if (result != type && TREE_CODE (type) == POINTER_TYPE - && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE) + && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE + && TYPE_LANG_SPECIFIC (result) == TYPE_LANG_SPECIFIC (type)) TYPE_LANG_SPECIFIC (result) = NULL; return result; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index feb6b5f8f54..fd3dba9345c 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4642,15 +4642,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, /* 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) + if (processing_template_decl || TREE_CODE (arg) != COMPONENT_REF) { val = build_address (arg); if (TREE_CODE (arg) == OFFSET_REF)