From 0f67bdf1cd15b11f00c1cc7476a33393ee77d938 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 5 Aug 2008 22:25:20 -0400 Subject: [PATCH] re PR c++/37016 (member function pointer failure with optimization) 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. From-SVN: r138756 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/decl.c | 9 +++++---- gcc/cp/tree.c | 3 ++- gcc/cp/typeck.c | 10 +--------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ff23cd..8ece21d 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 1ed98ee..69fa647 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 4114f86..ff19cd6 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 feb6b5f..fd3dba9 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) -- 2.7.4