Hi all,

Can gatekeeper help review this fix?
https://bugs.open64.net/show_bug.cgi?id=612

samll case:

struct A { };

typedef void (A::*pmf_void) ();

typedef void (A::*pmf_bool) (bool);

struct B

{
  pmf_void member () const  {  }
};

B *b;

void

die (bool param)

{
  pmf_bool pmf = (pmf_bool) (b->member ());
}

The bug happens when compile with above code with –m32, and ok with
m64. Through comparing the difference between m32 and m64, found that
the gspin node for "(pmf_bool) (b->member ())" function returns "ptr
to mem func" for m32, so it should call
"WGEN_Call_Returns_Ptr_To_Member_Func" to expand. There is already
code in wgen_expr.cxx, however for above case the gspin node for
"pmf_bool pmf = (pmf_bool) (b->member ());“ is:
GS_INIT_EXPR
    GS_VAR_DECL
    GS_NOP_EXPR
        GS_CALL_EXPR
The gs_tree_operand(exp, 1) is GS_NOP_EXPR not CALL_EXPR, so the fix
is to remove the nop node.
   7696         // If gs_tree_operand(exp, 1) is a CALL_EXPR that returns a
   7697         // ptr-to-member-function, then call
   7698         // WGEN_Expand_Ptr_To_Member_Func_Call_Expr to expand
it.  Otherwise,
   7699         // call WGEN_Expand_Expr to do regular expansion.  Bug 4737.
   7700         gs_t exp_opnd1 = gs_tree_operand(exp, 1);
   7701         if (WGEN_Call_Returns_Ptr_To_Member_Func(exp_opnd1)) {
   7702           TYPE_ID desc = TY_mtype(Get_TY(gs_tree_type(exp_opnd1)));
   7703           wn1 = WGEN_Expand_Ptr_To_Member_Func_Call_Expr(exp_opnd1, 0,
   7704
Widen_Mtype(desc), desc);
   7705         }

The patch is:
Index: wgen_expr.cxx
===================================================================
--- wgen_expr.cxx       (revision 3491)
+++ wgen_expr.cxx       (working copy)
@@ -7698,6 +7698,9 @@
        // WGEN_Expand_Ptr_To_Member_Func_Call_Expr to expand it.  Otherwise,
        // call WGEN_Expand_Expr to do regular expansion.  Bug 4737.
        gs_t exp_opnd1 = gs_tree_operand(exp, 1);
+        // Skip the NOP_EXPRs
+        while (gs_tree_code(exp_opnd1) == GS_NOP_EXPR)
+          exp_opnd1 = gs_tree_operand (exp_opnd1, 0);
        if (WGEN_Call_Returns_Ptr_To_Member_Func(exp_opnd1)) {
          TYPE_ID desc = TY_mtype(Get_TY(gs_tree_type(exp_opnd1)));
          wn1 = WGEN_Expand_Ptr_To_Member_Func_Call_Expr(exp_opnd1, 0,

Thanks
zhuqing

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to