From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120986 invoked by alias); 11 Sep 2017 12:58:01 -0000 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 Received: (qmail 120767 invoked by uid 89); 11 Sep 2017 12:58:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Sep 2017 12:57:58 +0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2017 05:57:56 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga005.jf.intel.com with ESMTP; 11 Sep 2017 05:57:55 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id v8BCvs4Y016530; Mon, 11 Sep 2017 13:57:54 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id v8BCvsPf029653; Mon, 11 Sep 2017 14:57:54 +0200 Received: (from twiederh@localhost) by ulvlx001.iul.intel.com with LOCAL id v8BCvs3X029649; Mon, 11 Sep 2017 14:57:54 +0200 From: Tim Wiederhake To: gdb-patches@sourceware.org Subject: [PATCH 2/5] Fortran: Move value_f90_subarray. Date: Mon, 11 Sep 2017 12:58:00 -0000 Message-Id: <1505134663-29374-3-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1505134663-29374-1-git-send-email-tim.wiederhake@intel.com> References: <1505134663-29374-1-git-send-email-tim.wiederhake@intel.com> X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00305.txt.bz2 2017-09-11 Tim Wiederhake gdb/ChangeLog: * eval.c (Evaluate_subexp_standard): Use new function name. (value_f90_subarray): Move ... * f-lang.c (f90_value_subarray): ... here. * f-lang.h (f90_value_subarray): New declaration. --- gdb/eval.c | 30 ++---------------------------- gdb/f-lang.c | 27 +++++++++++++++++++++++++++ gdb/f-lang.h | 5 +++++ 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index 7a808a0..557ac02 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -384,32 +384,6 @@ init_array_element (struct value *array, struct value *element, return index; } -static struct value * -value_f90_subarray (struct value *array, - struct expression *exp, int *pos, enum noside noside) -{ - int pc = (*pos) + 1; - LONGEST low_bound, high_bound; - struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array))); - enum range_type range_type - = (enum range_type) longest_to_int (exp->elts[pc].longconst); - - *pos += 3; - - if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) - low_bound = TYPE_LOW_BOUND (range); - else - low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); - - if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) - high_bound = TYPE_HIGH_BOUND (range); - else - high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); - - return value_slice (array, low_bound, high_bound - low_bound + 1); -} - - /* Promote value ARG1 as appropriate before performing a unary operation on this argument. If the result is not appropriate for any particular language then it @@ -1916,13 +1890,13 @@ evaluate_subexp_standard (struct type *expect_type, { case TYPE_CODE_ARRAY: if (exp->elts[*pos].opcode == OP_RANGE) - return value_f90_subarray (arg1, exp, pos, noside); + return f90_value_subarray (arg1, exp, pos, noside); else goto multi_f77_subscript; case TYPE_CODE_STRING: if (exp->elts[*pos].opcode == OP_RANGE) - return value_f90_subarray (arg1, exp, pos, noside); + return f90_value_subarray (arg1, exp, pos, noside); else { arg2 = evaluate_subexp_with_coercion (exp, pos, noside); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 77b759b..63caf65 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -386,3 +386,30 @@ f77_get_array_dims (const struct type *array_type) return ndimen; } + +/* See f-lang.h. */ + +struct value * +f90_value_subarray (struct value *array, struct expression *exp, int *pos, + enum noside noside) +{ + int pc = (*pos) + 1; + LONGEST low_bound, high_bound; + struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array))); + enum range_type range_type + = (enum range_type) longest_to_int (exp->elts[pc].longconst); + + *pos += 3; + + if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) + low_bound = TYPE_LOW_BOUND (range); + else + low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + + if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT) + high_bound = TYPE_HIGH_BOUND (range); + else + high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + + return value_slice (array, low_bound, high_bound - low_bound + 1); +} diff --git a/gdb/f-lang.h b/gdb/f-lang.h index cfe667b..013ea5e 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -59,6 +59,11 @@ extern void f77_get_dynamic_array_length (struct type *); * the type of an array. */ extern int f77_get_array_dims (const struct type *array_type); +/* Evaluates any subarray operation on Fortran arrays with at least one user + provided parameter. Expects the input ARRAY to be an array. */ +extern struct value *f90_value_subarray (struct value *array, + struct expression *exp, + int *pos, enum noside noside); /* Fortran (F77) types */ -- 2.7.4