From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30670 invoked by alias); 22 Nov 2012 07:32:45 -0000 Received: (qmail 30603 invoked by uid 22791); 22 Nov 2012 07:32:44 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Nov 2012 07:32:38 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1TbRH3-0001aG-Vs from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 21 Nov 2012 23:32:38 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 21 Nov 2012 23:32:37 -0800 Received: from qiyao.dyndns.org.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Wed, 21 Nov 2012 23:32:36 -0800 From: Yao Qi To: Subject: [PATCH 2/4] factor code Date: Thu, 22 Nov 2012 07:33:00 -0000 Message-ID: <1353569539-744-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1353569539-744-1-git-send-email-yao@codesourcery.com> References: <1353569539-744-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00595.txt.bz2 This is a code refactor to pave the way for the following patches. Functionality of GDB is not affected. gdb: 2012-11-22 Daniel Jacobowitz Yao Qi * eval.c (evaluate_subexp_standard): Code factor. --- gdb/eval.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index f655957..9957d02 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1364,7 +1364,6 @@ evaluate_subexp_standard (struct type *expect_type, alloca (sizeof (struct value *) * (nargs + 3)); if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) { - nargs++; /* First, evaluate the structure into arg2. */ pc2 = (*pos)++; @@ -1388,22 +1387,22 @@ evaluate_subexp_standard (struct type *expect_type, arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (TYPE_CODE (check_typedef (value_type (arg1))) - != TYPE_CODE_METHODPTR) - error (_("Non-pointer-to-member value used in pointer-to-member " - "construct")); - - if (noside == EVAL_AVOID_SIDE_EFFECTS) + type = check_typedef (value_type (arg1)); + if (TYPE_CODE (type) == TYPE_CODE_METHODPTR) { - struct type *method_type = check_typedef (value_type (arg1)); + if (noside == EVAL_AVOID_SIDE_EFFECTS) + arg1 = value_zero (type, not_lval); + else + arg1 = cplus_method_ptr_to_value (&arg2, arg1); - arg1 = value_zero (method_type, not_lval); + /* Now, say which argument to start evaluating from. */ + nargs++; + tem = 2; + argvec[1] = arg2; } else - arg1 = cplus_method_ptr_to_value (&arg2, arg1); - - /* Now, say which argument to start evaluating from. */ - tem = 2; + error (_("Non-pointer-to-member value used in pointer-to-member " + "construct")); } else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR) { @@ -1654,7 +1653,7 @@ evaluate_subexp_standard (struct type *expect_type, } else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) { - argvec[1] = arg2; + /* Pointer to member. argvec[1] is already set up. */ argvec[0] = arg1; } else if (op == OP_VAR_VALUE || (op == OP_SCOPE && function != NULL)) -- 1.7.7.6