From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104750 invoked by alias); 15 Sep 2017 20:27:24 -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 104741 invoked by uid 89); 15 Sep 2017 20:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 20:27:22 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v8FKRFm4007010 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 15 Sep 2017 16:27:20 -0400 Received: by simark.ca (Postfix, from userid 112) id 7F9C21ECF0; Fri, 15 Sep 2017 16:27:15 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 0D22B1EA9D; Fri, 15 Sep 2017 16:27:04 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 15 Sep 2017 20:27:00 -0000 From: Simon Marchi To: Tim Wiederhake Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/5] Fortran: Move value_f90_subarray. In-Reply-To: <1505134663-29374-3-git-send-email-tim.wiederhake@intel.com> References: <1505134663-29374-1-git-send-email-tim.wiederhake@intel.com> <1505134663-29374-3-git-send-email-tim.wiederhake@intel.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 15 Sep 2017 20:27:15 +0000 X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00425.txt.bz2 On 2017-09-11 14:57, Tim Wiederhake wrote: > 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 */ LGTM.