From patchwork Mon Sep 11 12:57:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wiederhake, Tim" X-Patchwork-Id: 22826 Received: (qmail 121292 invoked by alias); 11 Sep 2017 12:58:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 120898 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=1807, 3703 X-HELO: mga05.intel.com Received: from mga05.intel.com (HELO mga05.intel.com) (192.55.52.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Sep 2017 12:58:00 +0000 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 11 Sep 2017 05:57:55 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga005.fm.intel.com with ESMTP; 11 Sep 2017 05:57:54 -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 v8BCvsRO016528; 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 v8BCvswm029646; Mon, 11 Sep 2017 14:57:54 +0200 Received: (from twiederh@localhost) by ulvlx001.iul.intel.com with LOCAL id v8BCvrnk029642; Mon, 11 Sep 2017 14:57:54 +0200 From: Tim Wiederhake To: gdb-patches@sourceware.org Subject: [PATCH 1/5] Fortran: Move calc_f77_array_dims. Date: Mon, 11 Sep 2017 14:57:39 +0200 Message-Id: <1505134663-29374-2-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 2017-09-11 Tim Wiederhake gdb/ChangeLog: * eval.c (evaluate_subexp_standard): Use new function name. (calc_f77_array_dims): Move ... * f-lang.c (f77_get_array_dims): ... here. Constify argument. Make NULL check explicit. * f-lang.h (calc_f77_arra_dims): Rename to... (f77_get_array_dims): ... this. Add comment. * f-valprint.c (f77_print_array): Use new function name. --- gdb/eval.c | 21 +-------------------- gdb/f-lang.c | 16 ++++++++++++++++ gdb/f-lang.h | 4 +++- gdb/f-valprint.c | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index 24f32f8..7a808a0 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2336,7 +2336,7 @@ evaluate_subexp_standard (struct type *expect_type, if (nargs > MAX_FORTRAN_DIMS) error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS); - ndimensions = calc_f77_array_dims (type); + ndimensions = f77_get_array_dims (type); if (nargs != ndimensions) error (_("Wrong number of subscripts")); @@ -3266,22 +3266,3 @@ parse_and_eval_type (char *p, int length) error (_("Internal error in eval_type.")); return expr->elts[1].type; } - -int -calc_f77_array_dims (struct type *array_type) -{ - int ndimen = 1; - struct type *tmp_type; - - if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY)) - error (_("Can't get dimensions for a non-array type")); - - tmp_type = array_type; - - while ((tmp_type = TYPE_TARGET_TYPE (tmp_type))) - { - if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY) - ++ndimen; - } - return ndimen; -} diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 903cfd1..77b759b 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -370,3 +370,19 @@ _initialize_f_language (void) { f_type_data = gdbarch_data_register_post_init (build_fortran_types); } + +/* See f-lang.h. */ + +int +f77_get_array_dims (const struct type *array_type) +{ + if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY)) + error (_("Can't get dimensions for a non-array type")); + + int ndimen = 0; + for (; array_type != NULL; array_type = TYPE_TARGET_TYPE (array_type)) + if (TYPE_CODE (array_type) == TYPE_CODE_ARRAY) + ndimen += 1; + + return ndimen; +} diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 5633b41..cfe667b 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -55,7 +55,9 @@ extern int f77_get_lowerbound (struct type *); extern void f77_get_dynamic_array_length (struct type *); -extern int calc_f77_array_dims (struct type *); +/* Calculate the number of dimensions of an array. Expects ARRAY_TYPE to be + * the type of an array. */ +extern int f77_get_array_dims (const struct type *array_type); /* Fortran (F77) types */ diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 8fc894a..59d1a2f 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -180,7 +180,7 @@ f77_print_array (struct type *type, const gdb_byte *valaddr, int ndimensions; int elts = 0; - ndimensions = calc_f77_array_dims (type); + ndimensions = f77_get_array_dims (type); if (ndimensions > MAX_FORTRAN_DIMS || ndimensions < 0) error (_("\